<!DOCTYPE html><html><head>
      <title>7PHP&#x7C7B;&#x4E0E;&#x5BF9;&#x8C61;</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      
      <link rel="stylesheet" href="file:///C:\Users\Administrator\.vscode\extensions\shd101wyy.markdown-preview-enhanced-0.4.3\node_modules\@shd101wyy\mume\dependencies\katex\katex.min.css">
      
      

      
      
      
      
      
      

      <style>
      /**
 * prism.js Github theme based on GitHub's theme.
 * @author Sam Clarke
 */
code[class*="language-"],
pre[class*="language-"] {
  color: #333;
  background: none;
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.4;

  -moz-tab-size: 8;
  -o-tab-size: 8;
  tab-size: 8;

  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
  padding: .8em;
  overflow: auto;
  /* border: 1px solid #ddd; */
  border-radius: 3px;
  /* background: #fff; */
  background: #f5f5f5;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
  padding: .1em;
  border-radius: .3em;
  white-space: normal;
  background: #f5f5f5;
}

.token.comment,
.token.blockquote {
  color: #969896;
}

.token.cdata {
  color: #183691;
}

.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
  color: #333;
}

.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
  color: #a71d5d;
}

.token.string,
.token.url,
.token.regex,
.token.attr-value {
  color: #183691;
}

.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
  color: #0086b3;
}

.token.tag,
.token.selector,
.token.prolog {
  color: #63a35c;
}

.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
  color: #795da3;
}

.token.entity {
  cursor: help;
}

.token.title,
.token.title .token.punctuation {
  font-weight: bold;
  color: #1d3e81;
}

.token.list {
  color: #ed6a43;
}

.token.inserted {
  background-color: #eaffea;
  color: #55a532;
}

.token.deleted {
  background-color: #ffecec;
  color: #bd2c00;
}

.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}


/* JSON */
.language-json .token.property {
  color: #183691;
}

.language-markup .token.tag .token.punctuation {
  color: #333;
}

/* CSS */
code.language-css,
.language-css .token.function {
  color: #0086b3;
}

/* YAML */
.language-yaml .token.atrule {
  color: #63a35c;
}

code.language-yaml {
  color: #183691;
}

/* Ruby */
.language-ruby .token.function {
  color: #333;
}

/* Markdown */
.language-markdown .token.url {
  color: #795da3;
}

/* Makefile */
.language-makefile .token.symbol {
  color: #795da3;
}

.language-makefile .token.variable {
  color: #183691;
}

.language-makefile .token.builtin {
  color: #0086b3;
}

/* Bash */
.language-bash .token.keyword {
  color: #0086b3;
}

/* highlight */
pre[data-line] {
  position: relative;
  padding: 1em 0 1em 3em;
}
pre[data-line] .line-highlight-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  background-color: transparent;
  display: block;
  width: 100%;
}

pre[data-line] .line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  padding: inherit 0;
  margin-top: 1em;
  background: hsla(24, 20%, 50%,.08);
  background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
  pointer-events: none;
  line-height: inherit;
  white-space: pre;
}

pre[data-line] .line-highlight:before, 
pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-start);
  position: absolute;
  top: .4em;
  left: .6em;
  min-width: 1em;
  padding: 0 .5em;
  background-color: hsla(24, 20%, 50%,.4);
  color: hsl(24, 20%, 95%);
  font: bold 65%/1.5 sans-serif;
  text-align: center;
  vertical-align: .3em;
  border-radius: 999px;
  text-shadow: none;
  box-shadow: 0 1px white;
}

pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-end);
  top: auto;
  bottom: .4em;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{padding:0 1.6em;margin-top:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc li{margin-bottom:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{list-style-type:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% -  300px);padding:2em calc(50% - 457px -  150px);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */

      </style>
    </head>
    <body for="html-export">
      <div class="mume markdown-preview  ">
      <ul>
<li>&#x5173;&#x952E;&#x8BCD;&#xFF1A;&#x7C7B;&#xFF0C;&#x7C7B;&#x5B9E;&#x4F8B;&#xFF0C;&#x5BF9;&#x8C61;&#xFF0C;&#x5BF9;&#x8C61;&#x68C0;&#x6D4B;</li>
<li>&#x7C7B;&#x7684;&#x4E09;&#x5927;&#x7279;&#x6027;&#xFF1A;
<ul>
<li>&#x5C01;&#x88C5;&#xFF1A;&#x628A;&#x5BF9;&#x8C61;&#x7684;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;&#x7EC4;&#x7EC7;&#x5728;&#x4E00;&#x4E2A;&#x7C7B;&#xFF08;&#x903B;&#x8F91;&#x5355;&#x5143;&#xFF09;&#x91CC;</li>
<li>&#x7EE7;&#x627F;&#xFF1A;&#x4EE5;&#x539F;&#x6709;&#x7684;&#x7C7B;&#x4E3A;&#x57FA;&#x7840;&#xFF0C;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7C7B;&#xFF0C;&#x4ECE;&#x800C;&#x4EE3;&#x7801;&#x590D;&#x7528;&#x7684;&#x76EE;&#x7684;</li>
<li>&#x591A;&#x6001;&#xFF1A;&#x5141;&#x8BB8;&#x5C06;&#x5B50;&#x7C7B;&#x7C7B;&#x578B;&#x7684;&#x6307;&#x9488;&#x8D4B;&#x503C;&#x7ED9;&#x7236;&#x7C7B;&#x7C7B;&#x578B;&#x7684;&#x6307;&#x9488;</li>
</ul>
</li>
</ul>
<blockquote>
<p>&#x9700;&#x8981;&#x7684;&#x6570;&#x636E;&#x5E93;</p>
</blockquote>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token constant">CREATE</span> <span class="token constant">TABLE</span> `user` <span class="token punctuation">(</span>
	`uid` <span class="token function">int</span><span class="token punctuation">(</span><span class="token number">11</span><span class="token punctuation">)</span> unsigned <span class="token constant">NOT</span> <span class="token keyword">NULL</span> <span class="token constant">AUTO_INCREMENT</span> <span class="token constant">COMMENT</span> <span class="token single-quoted-string string">&apos;&#x7528;&#x6237;ID&apos;</span><span class="token punctuation">,</span>
	`name` <span class="token function">varchar</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span> <span class="token constant">NOT</span> <span class="token keyword">NULL</span> <span class="token constant">COMMENT</span> <span class="token single-quoted-string string">&apos;&#x59D3;&#x540D;&apos;</span><span class="token punctuation">,</span>
	`age` <span class="token function">smallint</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span> unsigned <span class="token constant">NOT</span> <span class="token keyword">NULL</span> <span class="token constant">COMMENT</span> <span class="token single-quoted-string string">&apos;&#x5E74;&#x9F84;&apos;</span><span class="token punctuation">,</span>
	<span class="token constant">PRIMARY</span> <span class="token function">KEY</span> <span class="token punctuation">(</span>`uid`<span class="token punctuation">)</span>
<span class="token punctuation">)</span> <span class="token constant">ENGINE</span><span class="token operator">=</span>MyISAM <span class="token constant">AUTO_INCREMENT</span><span class="token operator">=</span><span class="token number">7</span> <span class="token keyword">DEFAULT</span> <span class="token constant">CHARSET</span><span class="token operator">=</span>utf8<span class="token punctuation">;</span>

<span class="token constant">INSERT</span> <span class="token constant">INTO</span> `user` <span class="token function">VALUES</span> <span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;1&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&#x6B27;&#x9633;&#x514B;&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;18&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token constant">INSERT</span> <span class="token constant">INTO</span> `user` <span class="token function">VALUES</span> <span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;2&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&#x8001;&#x987D;&#x7AE5;&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;50&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token constant">INSERT</span> <span class="token constant">INTO</span> `user` <span class="token function">VALUES</span> <span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;3&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&#x9EC4;&#x84C9;&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;33&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token constant">INSERT</span> <span class="token constant">INTO</span> `user` <span class="token function">VALUES</span> <span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;4&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&#x90ED;&#x9756;&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;18&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token constant">INSERT</span> <span class="token constant">INTO</span> `user` <span class="token function">VALUES</span> <span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;5&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&#x4E00;&#x706F;&#x5927;&#x5E08;&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;80&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token constant">INSERT</span> <span class="token constant">INTO</span> `user` <span class="token function">VALUES</span> <span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;6&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&#x6D2A;&#x4E03;&#x516C;&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;79&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</pre><hr>
<h3 class="mume-header" id="-%E4%B8%80-%E5%88%9B%E5%BB%BA%E7%B1%BB">:-: &#x4E00;&#x3001;&#x521B;&#x5EFA;&#x7C7B;</h3>

<ul>
<li>&#x7C7B;&#x4E0D;&#x597D;&#x7406;&#x89E3;&#xFF0C;&#x56E0;&#x4E3A;&#x6982;&#x5FF5;&#x592A;&#x62BD;&#x8C61;&#x3002;</li>
<li>&#x5148;&#x8BF4;&#x4E00;&#x4E2A;&#x6BD4;&#x8F83;&#x62BD;&#x8C61;&#x7684;&#xFF0C;&#x6BD4;&#x5982;&#x52A8;&#x7269;&#x662F;&#x4E00;&#x4E2A;&#x7C7B;&#xFF0C;&#x800C;&#x5154;&#x5B50;&#x3001;&#x732A;&#x3001;&#x732B;&#x72D7;&#xFF0C;&#x90FD;&#x662F;&#x52A8;&#x7269;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#x5316;&#x5BF9;&#x8C61;&#x3002;</li>
<li>&#x7C7B;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x5206;&#x7C7B;&#xFF0C;&#x4E00;&#x4E2A;&#x6E05;&#x5355;&#x3002;&#x8FD9;&#x4E2A;&#x7C7B;&#x6709;&#x4EC0;&#x4E48;&#xFF0C;&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x7C7B;&#xFF0C;&#x521B;&#x5EFA;&#x51FA;&#x5BF9;&#x8C61;&#x3002;</li>
<li>&#x5BF9;&#x8C61;&#x4E0D;&#x662F;&#x51ED;&#x7A7A;&#x51FA;&#x6765;&#x7684;&#xFF0C;&#x90FD;&#x662F;&#x901A;&#x8FC7;&#x7C7B;&#x521B;&#x5EFA;&#x51FA;&#x6765;&#x7684;&#x3002;&#x6240;&#x4EE5;&#x54B1;&#x4EEC;&#x662F;&#x5148;&#x5199;&#x7C7B;&#xFF0C;&#x5728;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#x3002;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token shell-comment comment"># &#x521B;&#x5EFA;&#x7C7B;</span>
<span class="token keyword">class</span> <span class="token class-name">Animal</span><span class="token punctuation">{</span>

<span class="token punctuation">}</span>
<span class="token shell-comment comment"># &#x8C03;&#x7528;&#x7C7B;&#xFF08;&#x5B9E;&#x4F8B;&#x5316;&#xFF09;</span>
<span class="token variable">$monkey</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Animal</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>    <span class="token comment">// &#x7334;&#x5B50;</span>
<span class="token variable">$rabbit</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Animal</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>    <span class="token comment">// &#x5154;&#x5B50;</span>
</pre><blockquote>
<p>[danger] &#x5907;&#xFF1A;&#x7C7B;&#x5982;&#x679C;&#x53EA;&#x80FD;&#x4F7F;&#x7528;&#x4E00;&#x6B21;&#xFF0C;&#x90A3;&#x6211;&#x4EEC;&#x6CA1;&#x5FC5;&#x987B;&#x7528;&#x7C7B;&#xFF0C;&#x6BCF;&#x6B21;&#x76F4;&#x63A5;&#x5199;&#x4EE3;&#x7801;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#x3002;&#x6240;&#x4EE5;&#x7C7B;&#x53EF;&#x4EE5;&#x5B9E;&#x4F8B;&#x5316;&#x591A;&#x6B21;&#xFF08;N&#x6B21;&#xFF09;&#xFF0C;&#x6B21;&#x6570;&#x65E0;&#x9650;&#x5236;&#x3002;</p>
</blockquote>
<ul>
<li>&#x540C;&#x4E00;&#x4E2A;&#x7C7B;&#x5B9E;&#x4F8B;&#x5316;&#x51FA;&#x6765;&#xFF0C;&#x5B83;&#x4EEC;&#x662F;&#x4E0D;&#x4E00;&#x6837;&#x7684;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token function">var_dump</span><span class="token punctuation">(</span><span class="token variable">$monkey</span> <span class="token operator">==</span> <span class="token variable">$rabbit</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>

<span class="token function">var_dump</span><span class="token punctuation">(</span><span class="token variable">$monkey</span> <span class="token operator">===</span> <span class="token variable">$rabbit</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
</pre><ul>
<li>&#x68C0;&#x6D4B;&#x5BF9;&#x8C61;&#x662F;&#x5426;&#x662F;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token function">var_dump</span><span class="token punctuation">(</span><span class="token variable">$monkey</span> <span class="token keyword">instanceof</span> <span class="token class-name">Animal</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
</pre><hr>
<h3 class="mume-header" id="-%E4%BA%8C-%E7%B1%BB%E5%B1%9E%E6%80%A7">:-: &#x4E8C;&#x3001;&#x7C7B;&#x5C5E;&#x6027;</h3>

<ul>
<li>&#x5173;&#x952E;&#x8BCD;: &#x7C7B;&#x5C5E;&#x6027;, &#x8BBF;&#x95EE;&#x9650;&#x5236;&#x7B26;, &#x52A8;&#x6001;&#x5C5E;&#x6027;</li>
</ul>
<blockquote>
<p>&#x5728;&#x7C7B;&#x91CC;&#x76F4;&#x63A5;&#x5199;&#x4EE3;&#x7801;&#xFF0C;&#x662F;&#x9519;&#x8BEF;&#x7684;</p>
</blockquote>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token shell-comment comment"># &#x9519;&#x8BEF;&#x793A;&#x4F8B;</span>
<span class="token keyword">class</span> <span class="token class-name">Animal</span><span class="token punctuation">{</span>
	<span class="token keyword">echo</span> <span class="token number">111</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><ul>
<li>&#x7C7B; &#x662F;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x7684;&#x96C6;&#x5408;&#xFF0C;&#x5B83;&#x91CC;&#x9762;&#x6709;&#x6210;&#x5458;&#x7684;&#x3002;</li>
<li>&#x7C7B;&#x91CC;&#x6210;&#x5458;&#x6709;&#x4E24;&#x79CD;&#xFF1A;&#x5C5E;&#x6027;(&#x53D8;&#x91CF;)&#x548C;&#x884C;&#x4E3A;(&#x65B9;&#x6CD5;)&#x3002;&#x4EFB;&#x4F55;&#x7C7B;&#xFF0C;&#x90FD;&#x6709;&#x5C5E;&#x6027;&#x548C;&#x884C;&#x4E3A;&#x3002;</li>
</ul>
<h4 class="mume-header" id="1-%E5%B1%9E%E6%80%A7%E5%8F%98%E9%87%8F">1&#x3001;<strong>&#x5C5E;&#x6027;(&#x53D8;&#x91CF;)</strong></h4>

<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">class</span> <span class="token class-name">People</span><span class="token punctuation">{</span>
	<span class="token variable">$name</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x6768;&#x5E42;&apos;</span><span class="token punctuation">;</span>	<span class="token comment">//&#x4F1A;&#x62A5;&#x9519;&#xFF0C;&#x5FC5;&#x987B;&#x6709;&#x4FEE;&#x9970;&#x7B26;</span>
	<span class="token variable">$age</span>  <span class="token operator">=</span> <span class="token number">31</span><span class="token punctuation">;</span>		<span class="token comment">//&#x4F1A;&#x62A5;&#x9519;&#xFF0C;&#x5FC5;&#x987B;&#x6709;&#x4FEE;&#x9970;&#x7B26;</span>
	<span class="token comment">// &#x5C5E;&#x6027; &#x8BBE;&#x7F6E;&#x4E86;&#x521D;&#x59CB;&#x503C;</span>
	<span class="token keyword">public</span> <span class="token variable">$name</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x6768;&#x5E42;&apos;</span><span class="token punctuation">;</span>
	<span class="token keyword">public</span> <span class="token variable">$age</span>  <span class="token operator">=</span> <span class="token number">31</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token shell-comment comment"># &#x5916;&#x90E8;&#x8BBF;&#x95EE;&#xFF1A;&#x9700;&#x8981;&#x901A;&#x8FC7;&#x8BBF;&#x95EE;&#x9650;&#x5B9A;&#x7B26;&#x3001;&#x6216;&#x4FEE;&#x9970;&#x7B26;</span>
<span class="token variable">$yangmi</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">People</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$yangmi</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">;</span>
</pre><ul>
<li>&#x5728;&#x7C7B;&#x4E2D;&#x58F0;&#x660E;&#x5C5E;&#x6027;&#x53D8;&#x91CF;&#x65F6;,&#x8BBE;&#x7F6E;&#x5B83;&#x7684;&#x4F5C;&#x7528;&#x57DF;</li>
<li>&#x4F5C;&#x7528;&#x57DF;(&#x4FEE;&#x9970;&#x7B26;)&#xFF1A;&#x76EE;&#x524D;&#x6211;&#x4EEC;&#x5148;&#x5B66;&#x4E60;public
<ul>
<li>public &#x516C;&#x6709;&#x7684;&#xFF0C;&#x7C7B;&#x5185;,&#x7C7B;&#x5916;,&#x5B50;&#x7C7B;&#x90FD;&#x662F;&#x53EF;&#x8BBF;&#x95EE;&#x7684;</li>
<li>protected &#x53D7;&#x4FDD;&#x62A4;&#x7684;&#xFF0C;&#x7C7B;&#x5185;&#xFF0C;&#x5B50;&#x7C7B;&#x90FD;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;</li>
<li>private &#x79C1;&#x6709;&#x7684;&#xFF0C;&#x53EA;&#x80FD;&#x7C7B;&#x5185;&#x8BBF;&#x95EE;</li>
</ul>
</li>
</ul>
<blockquote>
<p>&#x5C5E;&#x6027;&#x91CD;&#x65B0;&#x8D4B;&#x503C;</p>
</blockquote>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token variable">$yangmi</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x6B27;&#x9633;&#x514B;&apos;</span><span class="token punctuation">;</span>
<span class="token variable">$yangmi</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token operator">=</span> <span class="token number">18</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$yangmi</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">.</span><span class="token variable">$yangmi</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span><span class="token punctuation">;</span>
</pre><h4 class="mume-header" id="2-%E8%A1%8C%E4%B8%BA%E6%96%B9%E6%B3%95">2&#x3001;<strong>&#x884C;&#x4E3A;(&#x65B9;&#x6CD5;)</strong></h4>

<ul>
<li>&#x5173;&#x952E;&#x8BCD;: self,  $this</li>
<li>&#x6BCF;&#x4E2A;&#x65B9;&#x6CD5;&#x91CC;&#xFF0C;&#x90FD;&#x5E26;&#x6709;$this&#xFF0C;&#x7528;&#x4F5C;&#x8C03;&#x7528;&#x81EA;&#x5DF1;&#x7C7B;&#x7684;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">class</span> <span class="token class-name">People</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x5C5E;&#x6027;</span>
	<span class="token keyword">public</span> <span class="token variable">$name</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x6768;&#x5E42;&apos;</span><span class="token punctuation">;</span>
	<span class="token keyword">public</span> <span class="token variable">$age</span> <span class="token operator">=</span> <span class="token number">31</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x65B9;&#x6CD5;&#xFF0C;&#x9ED8;&#x8BA4;&#x5C31;&#x662F;public &#xFF0C;&#x4E0D;&#x52A0;&#x4E5F;&#x662F;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x59D3;&#x540D;&#xFF1A;&#x6768;&#x5E42;&#xFF0C;&#x5E74;&#x9F84;&#xFF1A;31&apos;</span><span class="token punctuation">;</span>
		<span class="token keyword">return</span> <span class="token single-quoted-string string">&apos;&#x59D3;&#x540D;&#xFF1A;&#x6768;&#x5E42;&#xFF0C;&#x5E74;&#x9F84;&#xFF1A;31&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">getInfo1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// self : &#x5F53;&#x524D;&#x7C7B;</span>
		<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">self</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x8F93;&#x51FA;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;</span>
		<span class="token keyword">return</span>  <span class="token single-quoted-string string">&apos;&#x59D3;&#x540D;: &apos;</span> <span class="token punctuation">.</span><span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;, &#x5E74;&#x9F84;: &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">getInfo2</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x56E0;&#x4E3A;&#x8BE5;&#x65B9;&#x6CD5;&#x5FC5;&#x987B;&#x901A;&#x8FC7;&#x5BF9;&#x8C61;&#x8C03;&#x7528;,&#x6240;&#x6709;&#x6CA1;&#x5FC5;&#x8981;&#x5728;&#x7C7B;&#x4E2D;&#x5B9E;&#x4F8B;&#x5316;</span>
		<span class="token comment">// &#x76F4;&#x63A5;&#x5F15;&#x7528;&#x8BE5;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#x5316;&#x5BF9;&#x8C61;&#x5373;&#x53EF;</span>
		<span class="token comment">// &#x5728;&#x7C7B;&#x4E2D;&#x4F7F;&#x7528;&#x4F2A;&#x53D8;&#x91CF;: &quot;$this&quot; &#x5F15;&#x7528;&#x5F53;&#x524D;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;</span>
		<span class="token comment">// $this = new self();  &#x76F8;&#x5F53;&#x4E8E;&#x5148;&#x6267;&#x884C;&#x4E86;&#x8FD9;&#x6761;&#x8BED;&#x53E5;,&#x5C3D;&#x7BA1;&#x4F60;&#x4E0D;&#x9700;&#x8981;&#x8FD9;&#x6837;&#x505A;</span>
		<span class="token keyword">return</span>  <span class="token single-quoted-string string">&apos;&#x59D3;&#x540D;: &apos;</span> <span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;, &#x5E74;&#x9F84;: &apos;</span> <span class="token punctuation">.</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">getInfo3</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x5F53;&#x524D;&#x7C7B;</span>
		<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">People</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x6B27;&#x9633;&#x514B;&apos;</span><span class="token punctuation">;</span>
		<span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token operator">=</span> <span class="token number">18</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x8F93;&#x51FA;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;</span>
		<span class="token keyword">return</span>  <span class="token single-quoted-string string">&apos;&#x59D3;&#x540D;: &apos;</span> <span class="token punctuation">.</span><span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;, &#x5E74;&#x9F84;: &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x7C7B;&#x5B9E;&#x4F8B;&#x5316;</span>
<span class="token variable">$yangmi</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">People</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$yangmi</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$yangmi</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$yangmi</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo2</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$yangmi</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo3</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// &#x67E5;&#x770B;&#x7C7B;&#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;: public &#x624D;&#x4F1A;&#x663E;&#x793A;&#x51FA;&#x6765;</span>
<span class="token variable">$methods</span> <span class="token operator">=</span> <span class="token function">get_class_methods</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;People&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;pre&gt;&apos;</span><span class="token punctuation">.</span><span class="token function">print_r</span><span class="token punctuation">(</span><span class="token variable">$methods</span><span class="token punctuation">,</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><hr>
<h3 class="mume-header" id="-%E4%B8%89-%E6%9E%84%E9%80%A0%E6%96%B9%E6%B3%95%E9%AD%94%E6%9C%AF%E6%96%B9%E6%B3%95">:-: &#x4E09;&#x3001;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#xFF08;&#x9B54;&#x672F;&#x65B9;&#x6CD5;&#xFF09;</h3>

<ul>
<li>&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x662F;&#x7C7B;&#x4E2D;&#x7684;&#x7279;&#x6B8A;&#x65B9;&#x6CD5;,&#x5728;&#x7C7B;&#x5B9E;&#x4F8B;&#x5316;&#x65F6;&#x4F1A;&#x88AB;&#x81EA;&#x52A8;&#x8C03;&#x7528;,&#x53EF;&#x7528;&#x6765;&#x521D;&#x59CB;&#x5316;&#x5BF9;&#x8C61;&#x6210;&#x5458;</li>
<li>&#x8C03;&#x7528;&#x7C7B;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x7ACB;&#x5373;&#x6267;&#x884C;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x6267;&#x884C;&#x7684;&#x65B9;&#x6CD5;&#x3002;&#x65B9;&#x6CD5;&#x7684;&#x6CA1;&#x6709;&#x4F4D;&#x7F6E;&#x7684;&#x5148;&#x540E;&#x987A;&#x5E8F;</li>
<li>&#x6784;&#x9020;&#x65B9;&#x6CD5;: <code>public function __construct(){...}</code> &#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x8DDF;&#x7C7B;&#x540D;&#x4E00;&#x6837;&#x7684;&#x65B9;&#x6CD5;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">class</span> <span class="token class-name">People</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x5C5E;&#x6027;</span>
	<span class="token keyword">public</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
	<span class="token keyword">public</span> <span class="token variable">$age</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$age</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x5F00;&#x59CB;&#x6267;&#x884C;&apos;</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token operator">=</span> <span class="token variable">$age</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span>  <span class="token single-quoted-string string">&apos;&#x59D3;&#x540D;: &apos;</span> <span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;, &#x5E74;&#x9F84;: &apos;</span> <span class="token punctuation">.</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x5B9E;&#x4F8B;&#x5316;</span>
<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">People</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x6768;&#x5E42;&apos;</span><span class="token punctuation">,</span><span class="token number">31</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</pre><hr>
<h3 class="mume-header" id="-%E5%9B%9B-%E6%9E%90%E6%9E%84%E6%96%B9%E6%B3%95%E9%AD%94%E6%9C%AF%E6%96%B9%E6%B3%95">:-: &#x56DB;&#x3001;&#x6790;&#x6784;&#x65B9;&#x6CD5;&#xFF08;&#x9B54;&#x672F;&#x65B9;&#x6CD5;&#xFF09;</h3>

<ul>
<li>&#x6790;&#x6784;&#x65B9;&#x6CD5;&#x662F;&#x7C7B;&#x4E2D;&#x7684;&#x7279;&#x6B8A;&#x65B9;&#x6CD5;,&#x5728;&#x7C7B;&#x6267;&#x884C;&#x5B8C;&#x524D;&#xFF0C;&#x81EA;&#x52A8;&#x8C03;&#x7528;&#x3002;&#x53EF;&#x4EE5;&#x91CA;&#x653E;&#xFF0C;&#x5173;&#x95ED;&#x4E00;&#x4E9B;&#x8D44;&#x6E90;</li>
<li>&#x6784;&#x9020;&#x65B9;&#x6CD5;: <code>public function __destruct(){...}</code> &#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x8DDF;&#x7C7B;&#x540D;&#x4E00;&#x6837;&#x7684;&#x65B9;&#x6CD5;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">class</span> <span class="token class-name">People</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x5C5E;&#x6027;</span>
	<span class="token keyword">public</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
	<span class="token keyword">public</span> <span class="token variable">$age</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$age</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x5F00;&#x59CB;&#x6267;&#x884C;&apos;</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token operator">=</span> <span class="token variable">$age</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span>  <span class="token single-quoted-string string">&apos;&#x59D3;&#x540D;: &apos;</span> <span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;, &#x5E74;&#x9F84;: &apos;</span> <span class="token punctuation">.</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x6790;&#x6784;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__destruct</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x7C7B;&#x6267;&#x884C;&#x5B8C;&#x6BD5;&#xFF0C;&#x8981;&#x5173;&#x95ED;&#x4E86;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x5B9E;&#x4F8B;&#x5316;</span>
<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">People</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x6768;&#x5E42;&apos;</span><span class="token punctuation">,</span><span class="token number">31</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span> <span class="token comment">// &#x5982;&#x679C;&#x6CA1;&#x6709;&#x624B;&#x52A8;&#x91CA;&#x653E;&#xFF0C;&#x5C31;&#x4F1A;&#x5728;&#x6700;&#x540E;&#x6267;&#x884C;&#x6790;&#x6784;&#x65B9;&#x6CD5;</span>
</pre><blockquote>
<p>&#x5B9E;&#x6218;&#xFF1A;&#x81EA;&#x52A8;&#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;</p>
</blockquote>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">class</span> <span class="token class-name">Db</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x8FDE;&#x63A5;&#x53C2;&#x6570;</span>
	<span class="token keyword">public</span> <span class="token variable">$dsn</span><span class="token punctuation">;</span>
	<span class="token keyword">public</span> <span class="token variable">$user</span><span class="token punctuation">;</span>
	<span class="token keyword">public</span> <span class="token variable">$password</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x8FDE;&#x63A5;&#x5C5E;&#x6027;</span>
	<span class="token keyword">public</span> <span class="token variable">$pdo</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x8FDE;&#x63A5;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">connect</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x4F7F;&#x7528;PDO&#x65B9;&#x5F0F;&#x7BA1;&#x7406;&#x6570;&#x636E;&#x5E93;, &#x8FDE;&#x63A5;&#x6210;&#x529F;&#x5219;&#x8FD4;&#x56DE;PDO&#x5BF9;&#x8C61;,&#x8D4B;&#x503C;&#x7ED9;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;pdo</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">pdo</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">PDO</span><span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">dsn</span><span class="token punctuation">,</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">user</span><span class="token punctuation">,</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">password</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x5E0C;&#x671B;&#x5728;&#x5B9E;&#x4F8B;&#x5316;&#x65F6;, &#x81EA;&#x52A8;&#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;, &#x8FD9;&#x4E2A;&#x9700;&#x6C42;&#x5F88;&#x5E38;&#x89C1;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$dsn</span><span class="token punctuation">,</span> <span class="token variable">$user</span><span class="token punctuation">,</span> <span class="token variable">$password</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x521D;&#x59CB;&#x5316;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">dsn</span> <span class="token operator">=</span> <span class="token variable">$dsn</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">user</span> <span class="token operator">=</span> <span class="token variable">$user</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">password</span> <span class="token operator">=</span> <span class="token variable">$password</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x81EA;&#x52A8;&#x8C03;&#x7528;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;,&#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">connect</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x6790;&#x6784;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__destruct</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">pdo</span> <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x5B9E;&#x4F8B;&#x5316;</span>
<span class="token variable">$db</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Db</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;mysql:host=localhost;dbname=ouyangke&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;root&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;root&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$db</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">pdo</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
	<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;h2&gt;&#x8FDE;&#x63A5;&#x6210;&#x529F;&lt;/h2&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x8BFB;&#x53D6;&#x6570;&#x636E;&#x5E93;&#x6D4B;&#x8BD5;</span>
<span class="token variable">$stmt</span> <span class="token operator">=</span> <span class="token variable">$db</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">pdo</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">prepare</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;select * from user&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">execute</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">foreach</span> <span class="token punctuation">(</span><span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">fetchAll</span><span class="token punctuation">(</span><span class="token scope">PDO<span class="token punctuation">::</span></span><span class="token constant">FETCH_ASSOC</span><span class="token punctuation">)</span> <span class="token keyword">as</span> <span class="token variable">$user</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
	<span class="token function">print_r</span><span class="token punctuation">(</span><span class="token variable">$user</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><hr>
<h3 class="mume-header" id="-%E4%BA%94-%E7%B1%BB%E7%9A%84%E7%BB%A7%E6%89%BF%E7%B1%BB%E7%9A%84%E7%AC%AC%E4%B8%80%E7%89%B9%E7%82%B9">:-: &#x4E94;&#x3001;&#x7C7B;&#x7684;&#x7EE7;&#x627F;&#xFF1A;&#x7C7B;&#x7684;&#x7B2C;&#x4E00;&#x7279;&#x70B9;</h3>

<ul>
<li>&#x529F;&#x80FD;&#x6269;&#x5C55;, &#x65B9;&#x6CD5;&#x91CD;&#x5199;</li>
<li>&#x7EE7;&#x627F;&#x53EA;&#x80FD;&#x5355;&#x96C6;&#x6210;&#xFF0C;&#x4E0D;&#x80FD;&#x7EE7;&#x627F;&#x591A;&#x4E2A;&#x7236;&#x7C7B;</li>
<li>&#x7EE7;&#x627F;&#x65B9;&#x4FBF;&#x6269;&#x5C55;&#xFF0C;&#x7EF4;&#x62A4;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">class</span> <span class="token class-name">People</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x5BF9;&#x8C61;&#x5C5E;&#x6027;</span>
	<span class="token keyword">public</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
	<span class="token keyword">public</span> <span class="token variable">$age</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$age</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token operator">=</span> <span class="token variable">$age</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span>  <span class="token single-quoted-string string">&apos;&#x59D3;&#x540D;: &apos;</span> <span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;, &#x5E74;&#x9F84;: &apos;</span> <span class="token punctuation">.</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x5B50;&#x7C7B;Sub1, &#x4EE3;&#x7801;&#x590D;&#x7528;</span>
<span class="token keyword">class</span> <span class="token class-name">Woman</span> <span class="token keyword">extends</span> <span class="token class-name">People</span><span class="token punctuation">{</span>
	<span class="token comment">// ...</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x5B9E;&#x4F8B;&#x5316;&#x5B50;&#x7C7B;Woman, &#x5C3D;&#x7BA1;&#x5B50;&#x7C7B;&#x4E2D;&#x65E0;&#x4EFB;&#x4F55;&#x6210;&#x5458;,&#x4F46;&#x662F;&#x5B83;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x8C03;&#x7528;&#x7236;&#x7C7B;People&#x4E2D;&#x7684;&#x5168;&#x90E8;&#x6210;&#x5458;</span>
<span class="token variable">$sub1</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Woman</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x6768;&#x5E42;&apos;</span><span class="token punctuation">,</span> <span class="token number">31</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$sub1</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
</pre><blockquote>
<p>&#x5B9E;&#x73B0;&#x5B50;&#x7C7B;&#x91CC;&#x7684;&#x65B9;&#x6CD5;</p>
</blockquote>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token comment">// &#x5B50;&#x7C7B;Woman, &#x589E;&#x52A0;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;,&#x6269;&#x5C55;&#x7236;&#x7C7B;&#x529F;&#x80FD;</span>
<span class="token keyword">class</span> <span class="token class-name">Woman</span> <span class="token keyword">extends</span> <span class="token class-name">People</span><span class="token punctuation">{</span>
	<span class="token keyword">public</span> <span class="token variable">$wages</span><span class="token punctuation">;</span>  <span class="token comment">// &#x5DE5;&#x8D44;</span>
	<span class="token comment">// &#x5B50;&#x7C7B;&#x7684;&#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$age</span><span class="token punctuation">,</span> <span class="token variable">$wages</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x8C03;&#x7528;&#x7236;&#x7C7B;&#x7684;&#x6784;&#x9020;&#x65B9;&#x6CD5;,&#x5426;&#x5219;&#x8FD8;&#x8981;&#x624B;&#x5DE5;&#x628A;&#x7236;&#x7C7B;&#x4E2D;&#x7684;&#x5C5E;&#x6027;&#x521D;&#x59CB;&#x5316;&#x8BED;&#x53E5;&#x5168;&#x90E8;&#x5199;&#x4E00;&#x904D;</span>
		<span class="token comment">// parent:: &#x8C03;&#x7528;&#x88AB;&#x8986;&#x5199;&#x7684;&#x7236;&#x7C7B;&#x65B9;&#x6CD5;&#x5185;&#x5BB9;</span>
		<span class="token scope"><span class="token keyword">parent</span><span class="token punctuation">::</span></span><span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$age</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x53EA;&#x9700;&#x8981;&#x6DFB;&#x52A0;&#x5B50;&#x7C7B;&#x4E2D;&#x7684;&#x6210;&#x5458;&#x521D;&#x59CB;&#x5316;&#x4EE3;&#x7801;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">wages</span> <span class="token operator">=</span> <span class="token variable">$wages</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x8BA1;&#x7B97;&#x4E00;&#x5E74;&#x5DE5;&#x8D44;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">total</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
	   <span class="token keyword">return</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">wages</span><span class="token operator">*</span><span class="token number">12</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x5B9E;&#x4F8B;&#x5316;&#x5B50;&#x7C7B;</span>
<span class="token variable">$sub2</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Woman</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x6768;&#x5E42;&apos;</span><span class="token punctuation">,</span><span class="token number">31</span><span class="token punctuation">,</span><span class="token number">500000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$sub2</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&#x7684;&#x5E74;&#x85AA;: &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$sub2</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">total</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
</pre><blockquote>
<p>&#x5B50;&#x7C7B;&#x91CD;&#x5199;&#x7236;&#x7C7B;&#x65B9;&#x6CD5;</p>
</blockquote>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token comment">// &#x5982;&#x679C;&#x7236;&#x7C7B;&#x6709;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x5B50;&#x7C7B;&#x4E5F;&#x7528;&#x4E86;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;</span>
<span class="token comment">// &#x7B2C;&#x4E09;&#x4E2A;&#x5B50;&#x7C7B;, &#x7EE7;&#x627F;&#x81EA;Woman, &#x800C;Star&#x53C8;&#x7EE7;&#x627F;&#x81EA;People,&#x8FD9;&#x5C31;&#x5F62;&#x6210;&#x4E86;&#x591A;&#x5C42;&#x7ED9;&#x7684;&#x7EE7;&#x627F;&#x5173;&#x7CFB;</span>
<span class="token keyword">class</span> <span class="token class-name">Star</span> <span class="token keyword">extends</span> <span class="token class-name">Woman</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x91CD;&#x5199;&#x7236;&#x7C7B;total()&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">total</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token variable">$total</span> <span class="token operator">=</span> <span class="token scope"><span class="token keyword">parent</span><span class="token punctuation">::</span></span><span class="token function">total</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x5224;&#x65AD;&#x5DE5;&#x8D44;&#x5355;&#x4F4D;</span>
		<span class="token keyword">switch</span> <span class="token punctuation">(</span><span class="token variable">$total</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
			<span class="token keyword">case</span> <span class="token variable">$total</span><span class="token operator">&gt;</span><span class="token number">100000000</span><span class="token punctuation">:</span>
				<span class="token variable">$total</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token variable">$total</span><span class="token operator">/</span><span class="token number">10000</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;&#x4EBF;&apos;</span><span class="token punctuation">;</span>
				<span class="token keyword">break</span><span class="token punctuation">;</span>
			<span class="token keyword">case</span> <span class="token variable">$total</span><span class="token operator">&gt;</span><span class="token number">10000</span><span class="token punctuation">:</span>
				<span class="token variable">$total</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token variable">$total</span><span class="token operator">/</span><span class="token number">10000</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;&#x4E07;&apos;</span><span class="token punctuation">;</span>
				<span class="token keyword">break</span><span class="token punctuation">;</span>
			<span class="token keyword">default</span><span class="token punctuation">:</span>
				<span class="token variable">$total</span> <span class="token operator">=</span> <span class="token variable">$total</span><span class="token punctuation">;</span>
				<span class="token keyword">break</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span>
		<span class="token keyword">return</span> <span class="token variable">$total</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x5B9E;&#x4F8B;&#x5316;&#x5B50;&#x7C7B;</span>
<span class="token variable">$sub3</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Star</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x6768;&#x5E42;&apos;</span><span class="token punctuation">,</span><span class="token number">31</span><span class="token punctuation">,</span><span class="token number">500000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$sub3</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&#x7684;&#x5E74;&#x85AA;: &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$sub3</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">total</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><ul>
<li>&#x5907;&#x6CE8;&#xFF1A;this,parent&#x5173;&#x952E;&#x5B57;
<ul>
<li>this&#x662F;&#x6307;&#x5411;&#x5F53;&#x524D;&#x5BF9;&#x8C61;&#xFF0C;&#x4E5F;&#x5305;&#x62EC;&#x7EE7;&#x627F;&#x7684;&#x3002;&#x4F46;&#x662F;&#x4F1A;&#x6709;&#x76F8;&#x540C;&#x7684;&#x65B9;&#x6CD5;&#x540D;&#xFF0C;this&#x662F;&#x5148;&#x627E;&#x672C;&#x7C7B;&#xFF0C;&#x5728;&#x4E0A;&#x7236;&#x7C7B;</li>
<li>parent&#x662F;&#x6307;&#x5411;&#x7236;&#x7C7B;&#xFF0C;&#x91CD;&#x5199;&#x65F6;&#xFF0C;&#x4F7F;&#x7528;&#x5230;&#x3002;&#x6216;&#x8005;&#x6709;&#x7236;&#x7C7B;&#x548C;&#x5B50;&#x7C7B;&#xFF0C;&#x6709;&#x76F8;&#x540C;&#x65B9;&#x6CD5;&#x65F6;&#xFF0C;&#x624D;&#x4F7F;&#x7528;&#x3002;</li>
</ul>
</li>
</ul>
<hr>
<h3 class="mume-header" id="-%E5%85%AD-%E7%B1%BB%E7%9A%84%E5%B0%81%E8%A3%85%E7%B1%BB%E7%9A%84%E7%AC%AC%E4%BA%8C%E7%89%B9%E7%82%B9">:-: &#x516D;&#x3001;&#x7C7B;&#x7684;&#x5C01;&#x88C5;&#xFF1A;&#x7C7B;&#x7684;&#x7B2C;&#x4E8C;&#x7279;&#x70B9;</h3>

<ul>
<li>&#x8BBF;&#x95EE;&#x63A7;&#x5236;&#x7B26;, public, protected, private
<ul>
<li>public: &#x9ED8;&#x8BA4;, &#x7C7B;&#x5185;,&#x7C7B;&#x5916;,&#x5B50;&#x7C7B;&#x90FD;&#x53EF;&#x89C1;</li>
<li>protected: &#x7C7B;&#x5185;, &#x5B50;&#x7C7B;&#x53EF;&#x89C1;, &#x7C7B;&#x5916;&#x4E0D;&#x53EF;&#x89C1;</li>
<li>private: &#x7C7B;&#x5185;&#x53EF;&#x89C1;, &#x5B50;&#x7C7B;, &#x7C7B;&#x5916;&#x4E0D;&#x53EF;&#x89C1;</li>
</ul>
</li>
</ul>
<blockquote>
<p>&#x6210;&#x5458;&#xFF08;&#x53D8;&#x91CF;&#xFF09;&#x7684;&#x5C01;&#x88C5;</p>
</blockquote>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">class</span> <span class="token class-name">Woman</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x5C5E;&#x6027;</span>
	<span class="token keyword">public</span> <span class="token variable">$name</span><span class="token punctuation">;</span>			<span class="token comment">// &#x59D3;&#x540D;</span>
	<span class="token keyword">protected</span> <span class="token variable">$age</span><span class="token punctuation">;</span>			<span class="token comment">// &#x5E74;&#x9F84;</span>
	<span class="token keyword">private</span> <span class="token variable">$wages</span><span class="token punctuation">;</span>			<span class="token comment">// &#x5DE5;&#x8D44;</span>
	<span class="token comment">// &#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$age</span><span class="token punctuation">,</span> <span class="token variable">$wages</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token operator">=</span> <span class="token variable">$age</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">wages</span> <span class="token operator">=</span> <span class="token variable">$wages</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x7C7B;&#x5B9E;&#x4F8B;&#x5316;</span>
<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Woman</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x6768;&#x5E42;&apos;</span><span class="token punctuation">,</span><span class="token number">31</span><span class="token punctuation">,</span><span class="token number">500000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>

<span class="token comment">// echo $obj-&gt;age, &apos;&lt;br&gt;&apos;;    // &#x4F1A;&#x62A5;&#x9519;</span>

<span class="token comment">// echo $obj-&gt;wages, &apos;&lt;br&gt;&apos;;    // &#x4F1A;&#x62A5;&#x9519;</span>

<span class="token comment">// &#x7EE7;&#x627F;&#x540E;&#x8BBF;&#x95EE;</span>
<span class="token keyword">class</span> <span class="token class-name">Star</span> <span class="token keyword">extends</span> <span class="token class-name">Woman</span><span class="token punctuation">{</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">info</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
		<span class="token keyword">echo</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
		<span class="token comment">// echo $this-&gt;wages, &apos;&lt;br&gt;&apos;;    // &#x4F1A;&#x62A5;&#x9519;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x7C7B;&#x5B9E;&#x4F8B;&#x5316;</span>
<span class="token variable">$obj1</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Star</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;baby&apos;</span><span class="token punctuation">,</span><span class="token number">28</span><span class="token punctuation">,</span><span class="token number">400000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">echo</span> <span class="token variable">$obj1</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>

<span class="token comment">// echo $obj-&gt;age, &apos;&lt;br&gt;&apos;;    // &#x4F1A;&#x62A5;&#x9519;</span>

<span class="token comment">// echo $obj-&gt;wages, &apos;&lt;br&gt;&apos;;    // &#x4F1A;&#x62A5;&#x9519;</span>

<span class="token keyword">echo</span> <span class="token variable">$obj1</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><blockquote>
<p>&#x884C;&#x4E3A;&#xFF08;&#x65B9;&#x6CD5;&#xFF09;&#x7684;&#x5C01;&#x88C5;</p>
</blockquote>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">class</span> <span class="token class-name">Woman</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x5C5E;&#x6027;</span>
	<span class="token keyword">public</span> <span class="token variable">$name</span><span class="token punctuation">;</span>			<span class="token comment">// &#x59D3;&#x540D;</span>
	<span class="token keyword">protected</span> <span class="token variable">$age</span><span class="token punctuation">;</span>			<span class="token comment">// &#x5E74;&#x9F84;</span>
	<span class="token keyword">private</span> <span class="token variable">$wages</span><span class="token punctuation">;</span>			<span class="token comment">// &#x5DE5;&#x8D44;</span>
	<span class="token comment">// &#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$age</span><span class="token punctuation">,</span> <span class="token variable">$wages</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token operator">=</span> <span class="token variable">$age</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">wages</span> <span class="token operator">=</span> <span class="token variable">$wages</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span> <span class="token single-quoted-string string">&apos;&#x6211;&#x7684;&#x540D;&#x5B57;&#x53EB;&#xFF1A;&apos;</span><span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token keyword">protected</span> <span class="token keyword">function</span> <span class="token function">age</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span> <span class="token single-quoted-string string">&apos;&#x6211;&#x7684;&#x5E74;&#x9F84;&#x662F;&#xFF1A;&apos;</span><span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token keyword">private</span> <span class="token keyword">function</span> <span class="token function">wages</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span> <span class="token single-quoted-string string">&apos;&#x6211;&#x7684;&#x5DE5;&#x8D44;&#x662F;&#xFF1A;&apos;</span><span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">wages</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">all</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token keyword">echo</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">age</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token keyword">echo</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">wages</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x7C7B;&#x5B9E;&#x4F8B;&#x5316;</span>
<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Woman</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x6768;&#x5E42;&apos;</span><span class="token punctuation">,</span><span class="token number">31</span><span class="token punctuation">,</span><span class="token number">500000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">//echo $obj-&gt;age();    // &#x4F1A;&#x62A5;&#x9519;</span>

<span class="token comment">//echo $obj-&gt;wages();    // &#x4F1A;&#x62A5;&#x9519;</span>

<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">all</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">class</span> <span class="token class-name">Star</span> <span class="token keyword">extends</span> <span class="token class-name">Woman</span><span class="token punctuation">{</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">info</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token keyword">echo</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">age</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">// echo $this-&gt;wages(); //&#x79C1;&#x6709;&#x7684;&#x4F1A;&#x62A5;&#x9519;</span>
	<span class="token punctuation">}</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">a</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">all</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x7C7B;&#x5B9E;&#x4F8B;&#x5316;</span>
<span class="token variable">$obj1</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Star</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;baby&apos;</span><span class="token punctuation">,</span><span class="token number">28</span><span class="token punctuation">,</span><span class="token number">400000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj1</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">a</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><hr>
<ul>
<li>&#x7C7B;&#x7684;&#x6587;&#x4EF6;&#x8D77;&#x540D;&#xFF1A;
<ul>
<li>&#x6709;&#x63CF;&#x8FF0;&#x610F;&#x4E49;&#xFF0C;&#x6BD4;&#x5982;&#xFF1A;&#x5973;&#x4EBA;woman</li>
<li>&#x7528;&#x4E8C;&#x7EA7;&#x547D;&#x540D;&#xFF0C;&#x6BD4;&#x5982;&#xFF1A;&#x5973;&#x4EBA;woman.class.php&#xFF0C; &#x4E8C;&#x7EA7;&#x547D;&#x540D;&#x662F;&#x544A;&#x8BC9;&#x7A0B;&#x5E8F;&#x5458;&#xFF0C;&#x4E0D;&#x76F4;&#x63A5;&#x8FD0;&#x884C;&#x7684;&#x6587;&#x4EF6;&#x3002;</li>
</ul>
</li>
<li>&#x4E00;&#x822C;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#xFF0C;&#x53EA;&#x4FDD;&#x5B58;&#x4E00;&#x4E2A;&#x7C7B;&#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x4F1A;&#x5728;&#x7C7B;&#x7684;&#x6587;&#x4EF6;&#x91CC;&#xFF0C;&#x8C03;&#x7528;&#x672C;&#x7C7B;&#x3002;
<ul>
<li>&#x90FD;&#x662F;&#x5728;&#x5916;&#x90E8;&#x8C03;&#x7528;&#x3002;&#x65B0;&#x5EFA;&#x4E2A;&#x6587;&#x4EF6;&#xFF0C;&#x8C03;&#x7528;&#x8FD9;&#x4E2A;&#x7C7B;&#x3002;include &apos;&#x7C7B;&#x6587;&#x4EF6;&apos;</li>
<li>include &apos;woman.class.php&apos;</li>
</ul>
</li>
</ul>
<table>
<thead>
<tr>
<th><strong>&#x5173;&#x952E;&#x8BCD;</strong></th>
<th><strong>&#x7C7B;&#x5916;&#x58F0;&#x660E;</strong></th>
<th><strong>&#x58F0;&#x660E;&#x7C7B;</strong></th>
<th><strong>&#x58F0;&#x660E;&#x5C5E;&#x6027;</strong></th>
<th><strong>&#x58F0;&#x660E;&#x65B9;&#x6CD5;</strong></th>
<th><strong>&#x89E3;&#x91CA;</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>const</td>
<td>&#x221A;</td>
<td></td>
<td>&#x221A;</td>
<td></td>
<td>&#x5B9A;&#x4E49;&#x7C7B;&#x5E38;&#x91CF;</td>
</tr>
<tr>
<td>extends</td>
<td></td>
<td>&#x221A;</td>
<td></td>
<td></td>
<td>&#x6269;&#x5C55;&#x7C7B;&#xFF0C;&#x7528;&#x4E00;&#x4E2A;&#x7C7B;&#x53BB;&#x6269;&#x5C55;&#x5B83;&#x7684;&#x7236;&#x7C7B;</td>
</tr>
<tr>
<td>public</td>
<td></td>
<td></td>
<td>&#x221A;</td>
<td>&#x221A;</td>
<td>&#x516C;&#x7528;&#x5C5E;&#x6027;&#x6216;&#x65B9;&#x6CD5;</td>
</tr>
<tr>
<td>protected</td>
<td></td>
<td></td>
<td>&#x221A;</td>
<td>&#x221A;</td>
<td>&#x79C1;&#x6709;&#x5C5E;&#x6027;&#x6216;&#x65B9;&#x6CD5;</td>
</tr>
<tr>
<td>private</td>
<td></td>
<td></td>
<td>&#x221A;</td>
<td>&#x221A;</td>
<td>&#x53D7;&#x4FDD;&#x62A4;&#x7684;&#x5C5E;&#x6027;&#x6216;&#x65B9;&#x6CD5;</td>
</tr>
<tr>
<td>abstract</td>
<td></td>
<td>&#x221A;</td>
<td>&#x221A;</td>
<td></td>
<td>&#x62BD;&#x8C61;&#x7C7B;&#x6216;&#x65B9;&#x6CD5;</td>
</tr>
<tr>
<td>final</td>
<td></td>
<td>&#x221A;</td>
<td></td>
<td>&#x221A;</td>
<td>&#x7C7B;&#x4E0D;&#x80FD;&#x88AB;&#x7EE7;&#x627F;</td>
</tr>
</tbody>
</table>
<hr>
<h3 class="mume-header" id="-%E4%B8%83-%E7%B1%BB%E5%B1%9E%E6%80%A7%E4%B8%8E%E7%B1%BB%E6%96%B9%E6%B3%95%E9%9D%99%E6%80%81%E6%88%90%E5%91%98">:-: &#x4E03;&#x3001;&#x7C7B;&#x5C5E;&#x6027;&#x4E0E;&#x7C7B;&#x65B9;&#x6CD5;(&#x9759;&#x6001;&#x6210;&#x5458;)</h3>

<ul>
<li>&#x7C7B;&#x5C5E;&#x6027;: &#x9759;&#x6001;&#x5C5E;&#x6027;</li>
<li>&#x7C7B;&#x65B9;&#x6CD5;: &#x9759;&#x6001;&#x65B9;&#x6CD5;</li>
<li>&#x9759;&#x6001;&#x6210;&#x5458;&#x5C5E;&#x4E8E;&#x7C7B;,&#x800C;&#x4E0D;&#x5C5E;&#x4E8E;&#x5BF9;&#x8C61;&#xFF08;&#x91CD;&#x70B9;&#xFF09;</li>
<li>&#x9759;&#x6001;&#x6210;&#x5458;&#x4E0D;&#x9700;&#x8981;&#x901A;&#x8FC7;&#x5BF9;&#x8C61;&#x8BBF;&#x95EE;,&#x6240;&#x4EE5;&#x4E0D;&#x5FC5;&#x5B9E;&#x4F8B;&#x5316;</li>
<li>&#x4F7F;&#x7528;<code>static</code>&#x5173;&#x952E;&#x5B57;&#x5B9A;&#x4E49;</li>
<li>&#x7C7B;&#x5916;&#x4F7F;&#x7528;&#x7C7B;&#x540D;&#x8BBF;&#x95EE;,&#x7C7B;&#x5185;&#x4F7F;&#x7528;<code>self</code>&#x8BBF;&#x95EE;</li>
<li>&#x7C7B;&#x5916;&#x90E8;, &#x7C7B;&#x5C5E;&#x6027;&#x4E0D;&#x80FD;&#x7528;&#x5B9E;&#x4F8B;&#x8BBF;&#x95EE;,&#x4F46;&#x7C7B;&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">class</span> <span class="token class-name">People</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x5C5E;&#x6027;</span>
	<span class="token keyword">public</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x5C5E;&#x6027;</span>
	<span class="token keyword">public</span> <span class="token variable">$age</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x5C5E;&#x6027;: &#x9759;&#x6001;&#x5C5E;&#x6027;</span>
	<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token variable">$country</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x4E2D;&#x56FD;&apos;</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$age</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token operator">=</span> <span class="token variable">$age</span><span class="token punctuation">;</span>
		<span class="token comment">// $this-&gt;country = $country;	// &#x4F1A;&#x62A5;&#x9519;</span>
		<span class="token comment">// &#x5C3D;&#x7BA1;&#x53EF;&#x4EE5;&#x5728;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x4E2D;&#x521D;&#x59CB;&#x5316;&#x9759;&#x6001;&#x5C5E;&#x6027;,&#x4F46;&#x4E0D;&#x5EFA;&#x8BAE;&#x8FD9;&#x6837;&#x505A;,&#x5426;&#x5219;&#x9759;&#x6001;&#x5C5E;&#x6027;,&#x65E0;&#x6CD5;&#x5728;&#x5BF9;&#x8C61;&#x4E4B;&#x95F4;&#x5171;&#x4EAB;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x5BF9;&#x8C61;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">getInfo1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x7528;&#x5BF9;&#x8C61;&#x8BBF;&#x95EE;,&#x65B9;&#x6CD5;&#x4E2D;&#x8BBF;&#x95EE;&#x4E86;&#x9759;&#x6001;&#x5C5E;&#x6027;,&#x5B9E;&#x73B0;&#x4E86;&#x7C7B;&#x5C5E;&#x6027;&#x5728;&#x5BF9;&#x8C61;&#x4E2D;&#x7684;&#x5171;&#x4EAB;</span>
		<span class="token comment">// return $this-&gt;name . &apos;&#x5E74;&#x9F84;&#x662F;: &apos; . $this-&gt;age. &apos;&#x56FD;&#x5BB6;&#x662F;&#xFF1A;&apos; . $this-&gt;country; // &#x8FD9;&#x6837;&#x4F1A;&#x62A5;&#x9519;</span>
		<span class="token keyword">return</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&#x5E74;&#x9F84;&#x662F;: &apos;</span> <span class="token punctuation">.</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span><span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&#x56FD;&#x5BB6;&#x662F;&#xFF1A;&apos;</span> <span class="token punctuation">.</span> <span class="token scope"><span class="token keyword">self</span><span class="token punctuation">::</span></span><span class="token variable">$country</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x7C7B;&#x65B9;&#x6CD5;: &#x9759;&#x6001;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">function</span> <span class="token function">getInfo2</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x9759;&#x6001;&#x65B9;&#x6CD5;&#x662F;&#x7C7B;&#x65B9;&#x6CD5;, &#x4E0D;&#x80FD;&#x7528;&#x5BF9;&#x8C61;&#x8C03;&#x7528;,&#x6240;&#x4EE5;&#x5185;&#x90E8;&#x4E5F;&#x4E0D;&#x5141;&#x8BB8;&#x4F7F;&#x7528;&#x5BF9;&#x8C61;&#x5F15;&#x7528;$this</span>
		<span class="token comment">// &#x5982;&#x679C;&#x9759;&#x6001;&#x65B9;&#x6CD5;&#x4E2D;,&#x4E00;&#x5B9A;&#x8981;&#x7528;&#x5230;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x6216;&#x65B9;&#x6CD5;,&#x53EF;&#x4EE5;&#x7528;&#x53C2;&#x6570;&#x4F20;&#x5165;</span>
		<span class="token keyword">return</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&#x5E74;&#x9F84;&#x662F;: &apos;</span> <span class="token punctuation">.</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&#x56FD;&#x5BB6;&#x662F;&#xFF1A;&apos;</span> <span class="token punctuation">.</span> <span class="token scope"><span class="token keyword">self</span><span class="token punctuation">::</span></span><span class="token variable">$country</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x9759;&#x6001;&#x65B9;&#x6CD5;: &#x4EE5;&#x65B9;&#x6CD5;&#x4F20;&#x53C2;&#x65B9;&#x5F0F;&#x8C03;&#x7528;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;/&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">function</span> <span class="token function">getInfo3</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span><span class="token variable">$age</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// return $this-&gt;name; // &#x4F1A;&#x62A5;&#x9519;&#xFF0C;&#x5728;&#x9759;&#x6001;&#x65B9;&#x6CD5;&#x91CC;&#xFF0C;&#x4E0D;&#x80FD;&#x8BBF;&#x95EE;&#x975E;&#x9759;&#x6001;&#x6210;&#x5458;</span>
		<span class="token comment">// &#x53EF;&#x4EE5;&#x7528;self&#x8C03;&#x7528;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x7528;&#x672C;&#x7C7B;&#x540D;&#x8C03;&#x7528;&#x3002; &#x6700;&#x597D;&#x5728;&#x672C;&#x7C7B;&#x7528;self&#xFF0C;&#x5728;&#x5916;&#x90E8;&#x7528;&#x7C7B;&#x540D;</span>
		<span class="token keyword">return</span> <span class="token variable">$name</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&#x5E74;&#x9F84;&#x662F;: &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$age</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&#x56FD;&#x5BB6;&#x662F;&#xFF1A;&apos;</span> <span class="token punctuation">.</span> <span class="token scope">Demo1<span class="token punctuation">::</span></span><span class="token variable">$country</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">People</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x8303;&#x51B0;&#x51B0;&apos;</span><span class="token punctuation">,</span><span class="token number">33</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// echo $obj-&gt;country, &apos;&lt;br&gt;&apos;;	//&#x4F1A;&#x62A5;&#x9519;</span>
<span class="token keyword">echo</span> <span class="token scope">People<span class="token punctuation">::</span></span><span class="token variable">$country</span><span class="token punctuation">;</span>	<span class="token comment">// &#x5E94;&#x8BE5;&#x4EE5;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x8BBF;&#x95EE;&#x9759;&#x6001;&#x5C5E;&#x6027;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// echo $obj-&gt;getInfo2(), &apos;&lt;br&gt;&apos;;	// &#x4F1A;&#x62A5;&#x9519;</span>
<span class="token comment">// echo People::getInfo2(), &apos;&lt;br&gt;&apos;;	// &#x4F1A;&#x62A5;&#x9519;</span>
<span class="token keyword">echo</span> <span class="token scope">People<span class="token punctuation">::</span></span><span class="token function">getInfo3</span><span class="token punctuation">(</span><span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">,</span><span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x5BF9;&#x8C61;&#x4E0D;&#x80FD;&#x8BBF;&#x95EE;&#x9759;&#x6001;&#x5C5E;&#x6027;,&#x4F46;&#x662F;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x9759;&#x6001;&#x65B9;&#x6CD5;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo3</span><span class="token punctuation">(</span><span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">,</span><span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">// &#x9759;&#x6001;&#x6210;&#x5458;&#x53EF;&#x4EE5;&#x91CD;&#x65B0;&#x8D4B;&#x503C;&#x3002;&#x5728;&#x521B;&#x5EFA;&#x5F88;&#x591A;&#x5BF9;&#x8C61;&#xFF0C;&#x503C;&#x4E0D;&#x4F1A;&#x56E0;&#x4E3A;&#x521B;&#x5EFA;&#x7684;&#x5BF9;&#x8C61;&#x6539;&#x53D8;&#x3002;</span>
<span class="token scope">People<span class="token punctuation">::</span></span><span class="token variable">$country</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;china&apos;</span><span class="token punctuation">;</span>
<span class="token variable">$obj1</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">People</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x6768;&#x5E42;&apos;</span><span class="token punctuation">,</span><span class="token number">31</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token scope">People<span class="token punctuation">::</span></span><span class="token variable">$country</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><ul>
<li>&#x4E4B;&#x524D;,&#x5C06;&#x7C7B;&#x505A;&#x4E3A;&#x5BF9;&#x8C61;&#x7684;&#x6A21;&#x677F;, &#x8BBF;&#x95EE;&#x7C7B;&#x4E2D;&#x7684;&#x6210;&#x5458;,&#x5FC5;&#x987B;&#x5148;&#x5C06;&#x7C7B;&#x5B9E;&#x4F8B;&#x5316;,&#x901A;&#x8FC7;&#x5BF9;&#x8C61;&#x8BBF;&#x95EE;</li>
<li>&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x7F16;&#x7A0B;,&#x5B9E;&#x9645;&#x4E0A;&#x64CD;&#x4F5C;&#x90FD;&#x662F;&#x5BF9;&#x8C61;,&#x800C;&#x7C7B;,&#x4EC5;&#x505A;&#x4E3A;&#x751F;&#x6210;&#x5BF9;&#x8C61;&#x7684;&#x4EE3;&#x7801;&#x6A21;&#x677F;&#x800C;&#x5B58;&#x5728;</li>
<li>&#x800C;&#x5B9E;&#x9645;&#x60C5;&#x51B5;&#x5374;&#x5E76;&#x975E;&#x603B;&#x662F;&#x5982;&#x6B64;&#xFF0C;&#x8BD5;&#x60F3;&#x4E00;&#x4E0B;,&#x4EE5;&#x4E0B;&#x7684;&#x4E8C;&#x79CD;&#x573A;&#x666F;:
<ul>
<li>&#x5982;&#x679C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;,&#x6211;&#x4EEC;&#x4EC5;&#x4EC5;&#x53EA;&#x7528;&#x4E00;&#x6B21;,&#x8FD8;&#x6709;&#x5FC5;&#x8981;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#x5417;, &#x76F4;&#x63A5;&#x5C06;&#x7C7B;&#x53D8;&#x4E3A;&#x5BF9;&#x8C61;,&#x5C82;&#x4E0D;&#x662F;&#x66F4;&#x65B9;&#x4FBF;?</li>
<li>&#x5982;&#x679C;&#x591A;&#x4E2A;&#x5BF9;&#x8C61;&#x4E4B;&#x95F4;, &#x9700;&#x8981;&#x5171;&#x4EAB;&#x4E00;&#x4E9B;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;, &#x800C;&#x4ED6;&#x4EEC;&#x5FC5;&#x987B;&#x901A;&#x8FC7;&#x4E00;&#x4E2A;&#x4E2A;&#x72EC;&#x7ACB;&#x5BF9;&#x8C61;&#x8C03;&#x7528;&#x7684;,&#x65E0;&#x6CD5;&#x5171;&#x4EAB;,&#x600E;&#x4E48;&#x529E;?</li>
<li>&#x9759;&#x6001;&#x53EF;&#x4EE5;&#x516C;&#x7528;&#xFF0C;&#x53EA;&#x4F1A;&#x5728;&#x5185;&#x5B58;&#x4E2D;&#xFF0C;&#x751F;&#x6210;&#x4E00;&#x4EFD;&#x3002;</li>
<li>&#x9759;&#x6001;&#x53EA;&#x6709;&#x5728;&#x7A0B;&#x5E8F;&#x6267;&#x884C;&#x5B8C;&#xFF0C;&#x624D;&#x4F1A;&#x88AB;&#x91CA;&#x653E;&#x3002;</li>
<li>&#x80FD;&#x7528;&#x9759;&#x6001;&#xFF0C;&#x5C31;&#x591A;&#x7528;&#x9759;&#x6001;&#xFF0C;&#x9759;&#x6001;&#x6548;&#x7387;&#x9AD8;</li>
</ul>
</li>
<li>&#x4EE5;&#x4E0A;&#x60C5;&#x51B5;,&#x5C06;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;&#x76F4;&#x63A5;&#x5B9A;&#x4E49;&#x5728;&#x7C7B;&#x4E2D;, &#x76F4;&#x63A5;&#x7528;&#x7C7B;&#x8C03;&#x7528;, &#x5C31;&#x53EF;&#x4EE5;&#x89E3;&#x51B3;</li>
</ul>
<hr>
<h3 class="mume-header" id="-%E5%85%AB-%E7%B1%BB%E5%B8%B8%E9%87%8F">:-: &#x516B;&#x3001;&#x7C7B;&#x5E38;&#x91CF;</h3>

<ul>
<li>&#x7C7B;&#x5E38;&#x91CF;&#x4E5F;&#x7C7B;&#x5C5E;&#x6027;&#x4E00;&#x6837;,&#x4E5F;&#x662F;&#x5C5E;&#x4E8E;&#x7C7B;&#x7684;, &#x5FC5;&#x987B;&#x7528;&#x7C7B;&#x8BBF;&#x95EE;,&#x4E0D;&#x80FD;&#x7528;&#x5BF9;&#x8C61;&#x8BBF;&#x95EE;</li>
<li>&#x7C7B;&#x5E38;&#x91CF;&#x4E0E;&#x7C7B;&#x5C5E;&#x6027;&#x7684;&#x533A;&#x522B;&#x662F;: &#x7C7B;&#x5E38;&#x91CF;&#x4E0D;&#x5141;&#x8BB8;&#x4FEE;&#x6539;,&#x800C;&#x7C7B;&#x5C5E;&#x6027;&#x53EF;&#x4EE5;&#x4FEE;&#x6539;</li>
<li>&#x7C7B;&#x5E38;&#x91CF;&#x4E0E;&#x666E;&#x901A;&#x5E38;&#x91CF;&#x7684;&#x547D;&#x540D;&#x89C4;&#x5219;&#x662F;&#x4E00;&#x81F4;&#x7684;, &#x63A8;&#x8350;&#x4F7F;&#x7528;&#x5927;&#x5199;&#x5B57;&#x6BCD;&#x6216;&#x5927;&#x5199;&#x5B57;&#x6BCD;+&#x4E0B;&#x5212;&#x7EBF;</li>
<li>&#x7C7B;&#x5E38;&#x91CF;&#x4E0D;&#x9700;&#x8981;&#x8BBE;&#x7F6E;&#x8BBF;&#x95EE;&#x9650;&#x5236;&#x7B26;,&#x9ED8;&#x8BA4;&#x884C;&#x4E3A;&#x4E0E;<code>public</code>&#x662F;&#x4E00;&#x6837;&#x7684;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token function">define</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;COUNTRY&apos;</span><span class="token punctuation">,</span><span class="token single-quoted-string string">&apos;&#x4E2D;&#x56FD;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">class</span> <span class="token class-name">People</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x7C7B;&#x5E38;&#x91CF;&#x4E5F;&#x7C7B;&#x5C5E;&#x6027;&#x4E00;&#x6837;,&#x4E5F;&#x662F;&#x5C5E;&#x4E8E;&#x7C7B;&#x7684;, &#x5FC5;&#x987B;&#x7528;&#x7C7B;&#x8BBF;&#x95EE;,&#x4E0D;&#x80FD;&#x7528;&#x5BF9;&#x8C61;&#x8BBF;&#x95EE;</span>
	<span class="token keyword">const</span> <span class="token constant">COUNTRY</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x4E2D;&#x56FD;&apos;</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x7C7B;&#x5E38;&#x91CF;&#x4E0E;&#x7C7B;&#x5C5E;&#x6027;&#x7684;&#x533A;&#x522B;&#x662F;: &#x7C7B;&#x5E38;&#x91CF;&#x4E0D;&#x5141;&#x8BB8;&#x4FEE;&#x6539;,&#x800C;&#x7C7B;&#x5C5E;&#x6027;&#x53EF;&#x4EE5;&#x4FEE;&#x6539;</span>
	<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token variable">$sex</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x5973;&apos;</span><span class="token punctuation">;</span>
	<span class="token keyword">private</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x7C7B;&#x5E38;&#x91CF;&#x5728;&#x7C7B;&#x7684;&#x5185;&#x90E8;,&#x8BBF;&#x95EE;&#x65B9;&#x5F0F;&#x4E0E;&#x7C7B;&#x5C5E;&#x6027;&#x662F;&#x4E00;&#x6837;&#x7684;</span>
		<span class="token keyword">return</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;&#x7684;&#x6027;&#x522B;&#x662F;:&apos;</span> <span class="token punctuation">.</span> <span class="token scope"><span class="token keyword">self</span><span class="token punctuation">::</span></span><span class="token variable">$sex</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;,&#x56FD;&#x7C4D;&#x662F;: &apos;</span> <span class="token punctuation">.</span> <span class="token scope"><span class="token keyword">self</span><span class="token punctuation">::</span></span><span class="token constant">COUNTRY</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">People</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x5218;&#x8BD7;&#x8BD7;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// &#x8BBF;&#x95EE;&#x7C7B;&#x5C5E;&#x6027;</span>
<span class="token keyword">echo</span> <span class="token scope">People<span class="token punctuation">::</span></span><span class="token variable">$sex</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x8BBF;&#x95EE;&#x7C7B;&#x5E38;&#x91CF;</span>
<span class="token keyword">echo</span> <span class="token scope">People<span class="token punctuation">::</span></span><span class="token constant">COUNTRY</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x8BBF;&#x95EE;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;: &#x8BE5;&#x65B9;&#x6CD5;&#x53C8;&#x8BBF;&#x95EE;&#x4E86;&#x7C7B;&#x5C5E;&#x6027;&#x4E0E;&#x7C7B;&#x5E38;&#x91CF;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x4FEE;&#x6539;&#x7C7B;&#x5C5E;&#x6027;</span>
<span class="token scope">People<span class="token punctuation">::</span></span><span class="token variable">$sex</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x4FDD;&#x5BC6;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x4FEE;&#x6539;&#x7C7B;&#x5E38;&#x91CF;: &#x62A5;&#x9519;</span>
<span class="token comment">//People::COUNTRY = &apos;&#x7F8E;&#x56FD;&apos;;</span>
<span class="token comment">// &#x53EF;&#x4EE5;&#x770B;&#x5230;&#x7C7B;&#x5C5E;&#x6027;:$sex&#x53D1;&#x751F;&#x4E86;&#x53D8;&#x5316;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><hr>
<h3 class="mume-header" id="-%E4%B9%9D-%E5%B1%9E%E6%80%A7%E9%87%8D%E8%BD%BD">:-: &#x4E5D;&#x3001;&#x5C5E;&#x6027;&#x91CD;&#x8F7D;</h3>

<ul>
<li>&#x91CD;&#x8F7D;: &#x52A8;&#x6001;&#x7684;&#x521B;&#x5EFA;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;
<ul>
<li>&#x5F53;&#x8BBF;&#x95EE;&#x672A;&#x5B9A;&#x4E49;&#x6216;&#x4E0D;&#x53EF;&#x89C1;&#x7684;&#x5C5E;&#x6027;/&#x65B9;&#x6CD5;&#x65F6;, &#x91CD;&#x8F7D;&#x65B9;&#x6CD5;&#x4F1A;&#x81EA;&#x52A8;&#x8C03;&#x7528;</li>
<li>&quot;&#x5F53;&#x8BBF;&#x95EE;&#x672A;&#x5B9A;&#x4E49;&#x6216;&#x4E0D;&#x53EF;&#x89C1;&quot;, &#x7EDF;&#x79F0;&#x4E3A;: &quot;&#x4E0D;&#x53EF;&#x8BBF;&#x95EE;&quot;</li>
<li>PHP&#x4E2D;&#x7684;&#x91CD;&#x8F7D;,&#x662F;&#x901A;&#x8FC7;&quot;&#x9B54;&#x672F;&#x65B9;&#x6CD5;&quot;&#x5B9E;&#x73B0;</li>
<li>&quot;&#x9B54;&#x672F;&#x65B9;&#x6CD5;&quot;&#x662F;&#x7279;&#x6307;&#x5BA2;&#x6237;&#x7AEF;&#x4E0D;&#x80FD;&#x8BBF;&#x95EE;,&#x800C;&#x53EA;&#x80FD;&#x662F;&#x7CFB;&#x7EDF;&#x6839;&#x636E;&#x4E00;&#x5B9A;&#x6761;&#x4EF6;&#x81EA;&#x52A8;&#x8C03;&#x7528;</li>
<li>&#x6240;&#x6709;&#x91CD;&#x8F7D;&#x65B9;&#x6CD5;&#x5FC5;&#x987B;&#x58F0;&#x660E;&#x4E3A;: <code>public</code></li>
</ul>
</li>
<li>&#x91CD;&#x8F7D;&#x65B9;&#x6CD5;
<ul>
<li><code>__get($name)</code>: &#x5F53;&#x83B7;&#x53D6;&#x672A;&#x5B9A;&#x4E49;&#x53EF;&#x4E0D;&#x89C1;&#x5C5E;&#x6027;&#x65F6;&#x89E6;&#x53D1;&#xFF0C;&#x9700;&#x8981;&#x4E00;&#x4E2A;&#x53C2;&#x6570;</li>
<li><code>__set($name, $value)</code> :&#x5F53;&#x7ED9;&#x672A;&#x5B9A;&#x4E49;&#x53EF;&#x4E0D;&#x89C1;&#x5C5E;&#x6027;&#x8D4B;&#x503C;&#x65F6;&#x89E6;&#x53D1;&#xFF0C;&#x9700;&#x8981;&#x4E24;&#x4E2A;&#x53C2;&#x6570;</li>
<li><code>__isset($name)</code>: &#x5F53;&#x68C0;&#x6D4B;&#x672A;&#x5B9A;&#x4E49;&#x53EF;&#x4E0D;&#x89C1;&#x5C5E;&#x6027;&#x65F6;&#x89E6;&#x53D1;</li>
<li><code>__unset($name)</code>: &#x5F53;&#x6CE8;&#x9500;&#x672A;&#x5B9A;&#x4E49;&#x53EF;&#x4E0D;&#x89C1;&#x5C5E;&#x6027;&#x65F6;&#x89E6;&#x53D1;</li>
<li>&#x9B54;&#x672F;&#x65B9;&#x6CD5;&#xFF0C;&#x53EF;&#x4EE5;&#x7ED9;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#x3002;&#x5B83;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x53EF;&#x4EE5;&#x8FDB;&#x884C;&#x8D4B;&#x503C;&#x5224;&#x65AD;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x5171;&#x6709;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x968F;&#x4FBF;&#x8D4B;&#x503C;&#x3002;&#x76F4;&#x63A5;&#x590D;&#x5236;&#x4E0D;&#x80FD;&#x5224;&#x65AD;&#xFF0C;&#x7528;__get&#xFF0C;__set&#x53EF;&#x4EE5;&#x5224;&#x65AD;&#x4E00;&#x4E9B;&#x4E0D;&#x592A;&#x53EF;&#x80FD;&#x7684;&#x503C;&#x3002;&#x6BD4;&#x5982;&#x5E74;&#x9F84;&#xFF0C;&#x4E0D;&#x53EF;&#x80FD;&#x4F1A;&#x8D85;&#x8FC7;200&#x5C81;&#x3002;&#x6BD4;&#x5982;&#x5973;&#x670B;&#x53CB;&#xFF0C;&#x4E0D;&#x53EF;&#x80FD;&#x591A;&#x4E2A;&#x3002;</li>
</ul>
</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">class</span> <span class="token class-name">People</span><span class="token punctuation">{</span>
	<span class="token keyword">private</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
	<span class="token keyword">private</span> <span class="token variable">$age</span><span class="token punctuation">;</span>
	<span class="token keyword">protected</span> <span class="token variable">$country</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x4E2D;&#x56FD;&apos;</span><span class="token punctuation">;</span>
	<span class="token comment">// public $country = &apos;&#x4E2D;&#x56FD;&apos;;</span>
	<span class="token comment">// &#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$age</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token operator">=</span> <span class="token variable">$age</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// __get($name):&#x5F53;&#x83B7;&#x53D6;&#x672A;&#x5B9A;&#x4E49;&#x53EF;&#x4E0D;&#x89C1;&#x5C5E;&#x6027;&#x65F6;&#x89E6;&#x53D1;</span>
	<span class="token comment">// $name &#x662F;&#x5C5E;&#x6027;&#x540D;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__get</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$name</span> <span class="token operator">===</span> <span class="token single-quoted-string string">&apos;country&apos;</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
			<span class="token comment">// &#x4EC5;&#x5141;&#x8BB8;name==&apos;admin&apos;&#x7684;&#x7528;&#x6237;&#x53EF;&#x4EE5;&#x67E5;&#x770B;country&#x5B57;&#x6BB5;&#x5185;&#x5BB9;</span>
			<span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">===</span> <span class="token single-quoted-string string">&apos;admin&apos;</span><span class="token punctuation">)</span> <span class="token operator">?</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token variable">$name</span> <span class="token punctuation">:</span> <span class="token single-quoted-string string">&apos;&#x65E0;&#x6743;&#x67E5;&#x770B;&apos;</span><span class="token punctuation">;</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span>
		<span class="token keyword">return</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token variable">$name</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// __set($name, $value):&#x5F53;&#x7ED9;&#x672A;&#x5B9A;&#x4E49;&#x53EF;&#x4E0D;&#x89C1;&#x5C5E;&#x6027;&#x8D4B;&#x503C;&#x65F6;&#x89E6;&#x53D1;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__set</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$value</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x76F4;&#x63A5;&#x8FD4;&#x56DE;, &#x6781;&#x5C11;&#x8FD9;&#x6837;&#x505A;&#xFF0C;&#x8FD9;&#x6837;&#x505A;&#x76F8;&#x5F53;&#x4E8E;&#x628A;&#x7C7B;&#x5C5E;&#x6027;&#x76F4;&#x63A5;&#x8BBE;&#x7F6E;&#x4E3A;&#xFF1A;public</span>
		<span class="token comment">// $this-&gt;$name = $value;</span>
		<span class="token comment">// &#x6DFB;&#x52A0;&#x8FC7;&#x6EE4;&#x673A;&#x5236;</span>
		<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$name</span> <span class="token operator">===</span> <span class="token single-quoted-string string">&apos;age&apos;</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
		   <span class="token keyword">return</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">===</span> <span class="token single-quoted-string string">&apos;admin&apos;</span> <span class="token operator">?</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token variable">$name</span> <span class="token operator">=</span> <span class="token variable">$value</span> <span class="token punctuation">:</span> <span class="token single-quoted-string string">&apos;&#x65E0;&#x6743;&#x4FEE;&#x6539;&apos;</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span>
		<span class="token keyword">return</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token variable">$name</span> <span class="token operator">=</span> <span class="token variable">$value</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// __isset($name): &#x5F53;&#x68C0;&#x6D4B;&#x672A;&#x5B9A;&#x4E49;&#x53EF;&#x4E0D;&#x89C1;&#x5C5E;&#x6027;&#x65F6;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__isset</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">===</span> <span class="token single-quoted-string string">&apos;admin&apos;</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
			<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">isset</span><span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token variable">$name</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
				<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x5B58;&#x5728;&#x8BE5;&#x5C5E;&#x6027;&apos;</span><span class="token punctuation">;</span>
			<span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
				<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x6CA1;&#x6709;&#x8BE5;&#x5C5E;&#x6027;&apos;</span><span class="token punctuation">;</span>
			<span class="token punctuation">}</span>
		<span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
			<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x65E0;&#x6743;&#x68C0;&#x6D4B;&apos;</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span>
	<span class="token punctuation">}</span>
	<span class="token comment">//__unset($name): &#x5F53;&#x6CE8;&#x9500;&#x672A;&#x5B9A;&#x4E49;&#x53EF;&#x4E0D;&#x89C1;&#x5C5E;&#x6027;&#x65F6;&#x89E6;&#x53D1;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__unset</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">===</span> <span class="token single-quoted-string string">&apos;admin&apos;</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
			<span class="token function">unset</span><span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token variable">$name</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
			<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x65E0;&#x6CD5;&#x5220;&#x9664;&apos;</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">People</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x8FEA;&#x4E3D;&#x70ED;&#x5DF4;&apos;</span><span class="token punctuation">,</span> <span class="token number">26</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">country</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x600E;&#x4E48;&#x624D;&#x80FD;&#x67E5;&#x770B; country, &#x53EA;&#x80FD;&#x7528;&apos;admin&apos;&#x6765;&#x5B9E;&#x4F8B;&#x5316;</span>
<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">People</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;admin&apos;</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">country</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x76F4;&#x63A5;&#x4FEE;&#x6539; age, &#x7C7B;&#x4E2D;&#x6CA1;&#x6709;__set()&#x4F1A;&#x62A5;&#x9519;</span>
<span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span> <span class="token operator">=</span> <span class="token number">80</span><span class="token punctuation">;</span>
<span class="token comment">// &#x67E5;&#x770B;age&#x5B57;&#x6BB5;&#x503C;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x68C0;&#x6D4B;&#x662F;&#x5426;&#x5B58;&#x5728;age&#x5B57;&#x6BB5;</span>
<span class="token function">isset</span><span class="token punctuation">(</span><span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x5220;&#x9664;salary&#x5C5E;&#x6027;</span>
<span class="token function">unset</span><span class="token punctuation">(</span><span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token function">isset</span><span class="token punctuation">(</span><span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">age</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><hr>
<h3 class="mume-header" id="-%E5%8D%81-%E6%96%B9%E6%B3%95%E9%87%8D%E8%BD%BD">:-: &#x5341;&#x3001;&#x65B9;&#x6CD5;&#x91CD;&#x8F7D;</h3>

<ul>
<li><code>__call()</code>: &#x8BBF;&#x95EE;&#x672A;&#x5B9A;&#x4E49;&#x7684;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;&#x65F6;&#x4F1A;&#x81EA;&#x52A8;&#x8C03;&#x7528;&#x5B83;</li>
<li><code>__callStatic()</code>: &#x8BBF;&#x95EE;&#x672A;&#x5B9A;&#x4E49;&#x7684;&#x9759;&#x6001;&#x7C7B;&#x65B9;&#x6CD5;&#x65F6;&#x4F1A;&#x81EA;&#x52A8;&#x8C03;&#x7528;&#x5B83;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">class</span> <span class="token class-name">People</span><span class="token punctuation">{</span>
	<span class="token comment">// __call(): &#x8BBF;&#x95EE;&#x4E0D;&#x5B58;&#x5728;/&#x4E0D;&#x53EF;&#x89C1;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;&#x65F6;&#x89E6;&#x53D1;&#xFF0C;&#x6709;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x662F;&#x65B9;&#x6CD5;&#x540D;&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x65B9;&#x6CD5;&#x7684;&#x53C2;&#x6570;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__call</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$arguments</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span> <span class="token single-quoted-string string">&apos;&#x65B9;&#x6CD5;&#x540D;: &apos;</span><span class="token punctuation">.</span><span class="token variable">$name</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;&lt;br&gt;&#x65B9;&#x6CD5;&#x53C2;&#x6570;&#x5217;&#x8868;: &apos;</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&lt;pre&gt;&apos;</span><span class="token punctuation">.</span><span class="token function">print_r</span><span class="token punctuation">(</span><span class="token variable">$arguments</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;&#x4E0D;&#x5B58;&#x5728;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// __callStatic(): &#x8BBF;&#x95EE;&#x4E0D;&#x5B58;&#x5728;/&#x4E0D;&#x53EF;&#x89C1;&#x7684;&#x7C7B;&#x65B9;&#x6CD5;(&#x9759;&#x6001;)&#x65B9;&#x6CD5;&#x65F6;&#x89E6;&#x53D1;</span>
	<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">function</span> <span class="token function">__callStatic</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$arguments</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span> <span class="token single-quoted-string string">&apos;&#x65B9;&#x6CD5;&#x540D;: &apos;</span><span class="token punctuation">.</span><span class="token variable">$name</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;&lt;br&gt;&#x65B9;&#x6CD5;&#x53C2;&#x6570;&#x5217;&#x8868;: &apos;</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&lt;pre&gt;&apos;</span><span class="token punctuation">.</span><span class="token function">print_r</span><span class="token punctuation">(</span><span class="token variable">$arguments</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;&#x4E0D;&#x5B58;&#x5728;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">People</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// &#x8BBF;&#x95EE;&#x4E0D;&#x5B58;&#x5728;&#x6216;&#x65E0;&#x6743;&#x8BBF;&#x95EE;&#x7684;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;</span>
<span class="token keyword">echo</span> <span class="token variable">$obj</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo1</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token number">20</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x8BBF;&#x95EE;&#x4E0D;&#x5B58;&#x5728;&#x6216;&#x65E0;&#x6743;&#x8BBF;&#x95EE;&#x7684;&#x9759;&#x6001;&#x7C7B;&#x65B9;&#x6CD5;</span>
<span class="token keyword">echo</span> <span class="token scope">Demo4<span class="token punctuation">::</span></span><span class="token function">getInfo2</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;html&apos;</span><span class="token punctuation">,</span><span class="token single-quoted-string string">&apos;css&apos;</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;javascript&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><hr>
<h3 class="mume-header" id="-%E5%8D%81%E4%B8%80-%E5%B0%8F%E6%A1%88%E4%BE%8B">:-: &#x5341;&#x4E00;&#x3001;&#x5C0F;&#x6848;&#x4F8B;</h3>

<ul>
<li>call_user_func(<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>c</mi><mi>a</mi><mi>l</mi><mi>l</mi><mi>b</mi><mi>a</mi><mi>c</mi><mi>k</mi><mo stretchy="false">[</mo><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">callback[,</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault">c</span><span class="mord mathdefault">a</span><span class="mord mathdefault" style="margin-right:0.01968em;">l</span><span class="mord mathdefault" style="margin-right:0.01968em;">l</span><span class="mord mathdefault">b</span><span class="mord mathdefault">a</span><span class="mord mathdefault">c</span><span class="mord mathdefault" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mpunct">,</span></span></span></span>parameter...]): &#x4EE5;&#x51FD;&#x6570;&#x53C2;&#x6570;&#x7684;&#x65B9;&#x5F0F;,&#x6267;&#x884C;&#x4E00;&#x4E2A;&#x51FD;&#x6570;,&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x4EE5;&#x56DE;&#x8C03;&#x7684;&#x65B9;&#x5F0F;&#x6267;&#x884C;&#x51FD;&#x6570;</li>
<li>call_user_func_array(<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>c</mi><mi>a</mi><mi>l</mi><mi>l</mi><mi>b</mi><mi>a</mi><mi>c</mi><mi>k</mi><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">callback,</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8888799999999999em;vertical-align:-0.19444em;"></span><span class="mord mathdefault">c</span><span class="mord mathdefault">a</span><span class="mord mathdefault" style="margin-right:0.01968em;">l</span><span class="mord mathdefault" style="margin-right:0.01968em;">l</span><span class="mord mathdefault">b</span><span class="mord mathdefault">a</span><span class="mord mathdefault">c</span><span class="mord mathdefault" style="margin-right:0.03148em;">k</span><span class="mpunct">,</span></span></span></span>array): &#x529F;&#x80FD;&#x4E0E;call_user_func()&#x76F8;&#x540C;, &#x4EC5;&#x4EC5;&#x662F;&#x53C2;&#x6570;&#x4EE5;&#x6570;&#x7EC4;&#x5F62;&#x5F0F;&#x63D0;&#x4F9B;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">function</span> <span class="token function">sum</span><span class="token punctuation">(</span><span class="token variable">$a</span><span class="token punctuation">,</span> <span class="token variable">$b</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
	<span class="token keyword">return</span> <span class="token variable">$a</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos; + &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$b</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos; = &apos;</span> <span class="token punctuation">.</span> <span class="token punctuation">(</span><span class="token variable">$a</span><span class="token operator">+</span><span class="token variable">$b</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x6B63;&#x5E38;&#x51FD;&#x6570;&#x8C03;&#x7528;</span>
<span class="token keyword">echo</span> <span class="token function">sum</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">,</span> <span class="token number">40</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x4EE5;&#x56DE;&#x8C03;&#x7684;&#x65B9;&#x5F0F;&#x6267;&#x884C;&#x8BE5;&#x51FD;&#x6570;</span>
<span class="token keyword">echo</span> <span class="token function">call_user_func</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;sum&apos;</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// call_user_func_array(), &#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x6570;&#x7EC4;&#x683C;&#x5F0F;,&#x4E0D;&#x80FD;&#x7701;&#x7565;</span>
<span class="token keyword">echo</span> <span class="token function">call_user_func_array</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;sum&apos;</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">30</span><span class="token punctuation">,</span> <span class="token number">80</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><pre data-role="codeBlock" data-info="php" class="language-php"><span class="token comment">// &#x73B0;&#x5728;&#x6362;&#x4E2A;&#x601D;&#x8DEF;, &#x5C06;&#x51FD;&#x6570;&#x653E;&#x5728;&#x4E00;&#x4E2A;&#x7C7B;&#x4E2D;, &#x518D;&#x6765;&#x8C03;&#x7528;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;/&#x51FD;&#x6570;</span>
<span class="token keyword">class</span> <span class="token class-name">Test1</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x5BF9;&#x8C61;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">sum</span><span class="token punctuation">(</span><span class="token variable">$a</span><span class="token punctuation">,</span> <span class="token variable">$b</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span> <span class="token variable">$a</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos; + &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$b</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos; = &apos;</span> <span class="token punctuation">.</span> <span class="token punctuation">(</span><span class="token variable">$a</span><span class="token operator">+</span><span class="token variable">$b</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x5982;&#x679C;&#x4EE5;&#x56DE;&#x8C03;&#x65B9;&#x5F0F;&#x6267;&#x884C;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;&#x5462;?</span>
<span class="token variable">$obj</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Test1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token function">call_user_func</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token variable">$obj</span><span class="token punctuation">,</span><span class="token single-quoted-string string">&apos;sum&apos;</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x4EC5;&#x4EE5;call_user_func_array()&#x4E3E;&#x4F8B;, call_user_func()&#x539F;&#x7406;&#x4E00;&#x6837;</span>
<span class="token keyword">echo</span> <span class="token function">call_user_func_array</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token variable">$obj</span><span class="token punctuation">,</span><span class="token single-quoted-string string">&apos;sum&apos;</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x5982;&#x679C;&#x4EC5;&#x8C03;&#x7528;&#x4E00;&#x6B21;,&#x53EF;&#x4EE5;&#x7B80;&#x5316;&#x4E00;&#x4E0B;&#x5BF9;&#x8C61;&#x521B;&#x5EFA;&#x65B9;&#x5F0F;</span>
<span class="token keyword">echo</span> <span class="token function">call_user_func_array</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token keyword">new</span> <span class="token class-name">Test1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token single-quoted-string string">&apos;sum&apos;</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">15</span><span class="token punctuation">,</span><span class="token number">35</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><pre data-role="codeBlock" data-info="php" class="language-php"><span class="token comment">// &#x5982;&#x679C;&#x662F;&#x4E00;&#x4E2A;&#x9759;&#x6001;&#x65B9;&#x6CD5;,&#x5982;&#x679C;&#x8C03;&#x7528;&#x5462;&#xFF1F;</span>
<span class="token keyword">class</span> <span class="token class-name">Test2</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x5BF9;&#x8C61;&#x65B9;&#x6CD5; (&#x4E58;&#x6CD5;&#x8FD0;&#x7B97;)</span>
	<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">function</span> <span class="token function">mul</span><span class="token punctuation">(</span><span class="token variable">$a</span><span class="token punctuation">,</span> <span class="token variable">$b</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span> <span class="token variable">$a</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos; * &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$b</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos; = &apos;</span> <span class="token punctuation">.</span> <span class="token punctuation">(</span><span class="token variable">$a</span><span class="token operator">*</span><span class="token variable">$b</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x76F4;&#x63A5;&#x5C06;&#x7C7B;&#x540D;&#x4E0E;&#x65B9;&#x6CD5;&#x5199;&#x5728;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#x5373;&#x53EF;</span>
<span class="token keyword">echo</span> <span class="token function">call_user_func_array</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;Test2::mul&apos;</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x5C06;&#x7C7B;&#x540D;&#x4E0E;&#x7C7B;&#x65B9;&#x6CD5;&#x5206;&#x5F00;,&#x653E;&#x5728;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;&#x4E2D;</span>
<span class="token keyword">echo</span> <span class="token function">call_user_func_array</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;Test2&apos;</span><span class="token punctuation">,</span><span class="token single-quoted-string string">&apos;mul&apos;</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x7C7B;&#x540D;&#x662F;: &apos;</span><span class="token punctuation">.</span> <span class="token scope">Test2<span class="token punctuation">::</span></span><span class="token keyword">class</span><span class="token punctuation">;</span>  <span class="token comment">// &#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7C7B;&#x540D;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x6240;&#x4EE5;&#x8FD9;&#x6837;&#x5199;,&#x4E5F;&#x662F;&#x6B63;&#x786E;&#x7684;</span>
<span class="token keyword">echo</span> <span class="token function">call_user_func_array</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token scope">Test2<span class="token punctuation">::</span></span><span class="token keyword">class</span><span class="token punctuation">,</span><span class="token single-quoted-string string">&apos;mul&apos;</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token number">30</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</pre><blockquote>
<p>&#x4E0B;&#x9762;&#x662F;&#x4E00;&#x4E2A;sql&#x8BED;&#x53E5;&#x7C7B;&#x7684;&#x6848;&#x4F8B;</p>
</blockquote>
<ul>
<li>&#x7C7B;&#x65B9;&#x6CD5;&#x7684;&#x8DE8;&#x7C7B;&#x8C03;&#x7528;&#x7684;&#x5B9E;&#x73B0;&#xFF1A;&#x65B9;&#x6CD5;&#x91CD;&#x8F7D;&#x7684;&#x5E94;&#x7528;&#xFF0C;&#x6570;&#x636E;&#x5E93;&#x67E5;&#x8BE2;&#x7684;&#x94FE;&#x5F0F;&#x64CD;&#x4F5C;</li>
<li>&#x94FE;&#x5F0F;&#x8C03;&#x7528;&#x7684;&#x539F;&#x7406;&#x5206;&#x6790;&#xFF1A;&#x4EE5;&#x6A21;&#x62DF;ThinkPHP5.1&#x6846;&#x67B6;&#x4E2D;&#x7684;&#x6570;&#x636E;&#x5E93;&#x67E5;&#x8BE2;&#x6784;&#x9020;&#x5668;&#x4E3A;&#x6848;&#x4F8B;,&#x6765;&#x6F14;&#x793A;&#x65B9;&#x6CD5;&#x91CD;&#x8F7D;&#x7684;&#x7CBE;&#x5999;&#x4E4B;&#x5904;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">require</span> <span class="token single-quoted-string string">&apos;query.php&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">class</span> <span class="token class-name">Db</span>
<span class="token punctuation">{</span>
	<span class="token comment">// &#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;&#x5BF9;&#x8C61;</span>
	<span class="token keyword">protected</span> <span class="token keyword">static</span> <span class="token variable">$pdo</span> <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x6570;&#x636E;&#x5E93;&#x8FDE;&#x63A5;&#x65B9;&#x6CD5;, &#x6BCF;&#x6B21;&#x67E5;&#x8BE2;&#x65F6;&#x518D;&#x8FDE;&#x63A5;, &#x5B9E;&#x73B0;&#x771F;&#x6B63;&#x7684;&#x60F0;&#x6027;&#x8FDE;&#x63A5;,&#x8282;&#x7701;&#x7CFB;&#x7EDF;&#x5F00;&#x9500;</span>
	<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">function</span> <span class="token function">connection</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x4E3A;&#x7B80;&#x5316;,&#x8FD9;&#x91CC;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x5B57;&#x9762;&#x91CF;&#x53C2;&#x6570;&#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;,&#x771F;&#x5B9E;&#x9879;&#x76EE;&#x4E2D;&#x5E94;&#x8BE5;&#x5C06;&#x53C2;&#x6570;&#x653E;&#x5728;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;</span>
		<span class="token scope"><span class="token keyword">self</span><span class="token punctuation">::</span></span><span class="token variable">$pdo</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">PDO</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;mysql:host=localhost;dbname=ouyangke&apos;</span><span class="token punctuation">,</span><span class="token single-quoted-string string">&apos;root&apos;</span><span class="token punctuation">,</span><span class="token single-quoted-string string">&apos;root&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x8FD9;&#x662F;&#x67E5;&#x8BE2;&#x7C7B;&#x64CD;&#x4F5C;&#x7684;&#x5165;&#x53E3;, &#x901A;&#x8FC7;&#x9759;&#x6001;&#x9B54;&#x672F;&#x65B9;&#x6CD5;&#x8FDB;&#x884C;&#x8DF3;&#x8F6C;,&#x5B9E;&#x73B0;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;&#x7684;&#x8DE8;&#x7C7B;&#x8C03;&#x7528;</span>
	<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">function</span> <span class="token function">__callStatic</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">,</span> <span class="token variable">$arguments</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x521B;&#x5EFA;pdo&#x5BF9;&#x8C61;,&#x5E76;&#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;</span>
		<span class="token scope"><span class="token keyword">self</span><span class="token punctuation">::</span></span><span class="token function">connection</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x5B9E;&#x4F8B;&#x5316;&#x67E5;&#x8BE2;&#x7C7B;,&#x5C06;&#x8FDE;&#x63A5;&#x5BF9;&#x8C61;&#x505A;&#x4E3A;&#x53C2;&#x6570;</span>
		<span class="token variable">$query</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">query</span><span class="token punctuation">(</span><span class="token scope"><span class="token keyword">self</span><span class="token punctuation">::</span></span><span class="token variable">$pdo</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x6267;&#x884C;&#x67E5;&#x8BE2;&#x7C7B;Query&#x4E2D;&#x7684;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;, &#x6CE8;&#x610F;&#x53C2;&#x6570;&#x662F;&#x6570;&#x7EC4;,&#x6211;&#x53EA;&#x9700;&#x8981;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;:&#x8868;&#x540D;, &#x6240;&#x4EE5;&#x52A0;&#x4E86;&#x7D22;&#x5F15;&#x952E;&#x540D;</span>
		<span class="token keyword">return</span> <span class="token function">call_user_func_array</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token variable">$query</span><span class="token punctuation">,</span><span class="token variable">$name</span><span class="token punctuation">]</span><span class="token punctuation">,</span><span class="token punctuation">[</span><span class="token variable">$arguments</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token comment">// &#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x94FE;&#x5F0F;&#x8C03;&#x7528;</span>
<span class="token comment">// &#x4EE5;Db&#x7C7B;&#x505A;&#x5165;&#x6574;&#x6570;&#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;&#x7684;&#x5165;&#x53E3;, SQL&#x8BED;&#x53E5;&#x7684;&#x5404;&#x4E2A;&#x90E8;&#x5206;&#x7528;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;&#x63D0;&#x4F9B;</span>
<span class="token comment">// &#x94FE;&#x5F0F;&#x64CD;&#x4F5C;&#x662F;&#x73B0;&#x4EE3;PHP&#x6846;&#x67B6;&#x7684;&#x57FA;&#x7840;,&#x975E;&#x5E38;&#x6709;&#x7528;</span>
<span class="token variable">$users</span> <span class="token operator">=</span> <span class="token scope">Db<span class="token punctuation">::</span></span><span class="token function">table</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;user&apos;</span><span class="token punctuation">)</span>
		<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">field</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;uid,name,age&apos;</span><span class="token punctuation">)</span>
		<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">where</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;uid &gt; 1&apos;</span><span class="token punctuation">)</span>
		<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">limit</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span>
		<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">select</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// &#x904D;&#x5386;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;</span>
<span class="token keyword">foreach</span> <span class="token punctuation">(</span><span class="token variable">$users</span> <span class="token keyword">as</span> <span class="token variable">$user</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
	<span class="token function">print_r</span><span class="token punctuation">(</span><span class="token variable">$user</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><blockquote>
<p>query.php</p>
</blockquote>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token delimiter important">&lt;?php</span>
<span class="token comment">// &#x6570;&#x636E;&#x5E93;&#x67E5;&#x8BE2;&#x7C7B;</span>

<span class="token keyword">class</span> <span class="token class-name">query</span>
<span class="token punctuation">{</span>
	<span class="token comment">// &#x8FDE;&#x63A5;&#x5BF9;&#x8C61;</span>
	<span class="token keyword">public</span> <span class="token variable">$pdo</span> <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>

	<span class="token comment">// &#x6570;&#x636E;&#x8868;&#x540D;</span>
	<span class="token keyword">public</span> <span class="token variable">$table</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&apos;</span><span class="token punctuation">;</span>

	<span class="token comment">// &#x5B57;&#x6BB5;&#x5217;&#x8868;</span>
	<span class="token keyword">public</span> <span class="token variable">$field</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&apos;</span><span class="token punctuation">;</span>

	<span class="token comment">// &#x67E5;&#x8BE2;&#x6761;&#x4EF6;</span>
	<span class="token keyword">public</span> <span class="token variable">$where</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&apos;</span><span class="token punctuation">;</span>

	<span class="token comment">// &#x663E;&#x793A;&#x6570;&#x91CF;</span>
	<span class="token keyword">public</span> <span class="token variable">$limit</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

	<span class="token comment">// &#x6784;&#x9020;&#x65B9;&#x6CD5;,&#x521D;&#x59CB;&#x5316;&#x8FDE;&#x63A5;&#x5BF9;&#x8C61;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$pdo</span><span class="token punctuation">)</span>
	<span class="token punctuation">{</span>
		<span class="token comment">// &#x8FDE;&#x63A5;&#x5BF9;&#x8C61;&#x662F;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;&#x7684;&#x5171;&#x4EAB;&#x5C5E;&#x6027;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">pdo</span> <span class="token operator">=</span> <span class="token variable">$pdo</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x8C03;&#x7528;&#x8868;&#x540D;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">table</span><span class="token punctuation">(</span><span class="token variable">$tablName</span><span class="token punctuation">)</span>
	<span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">table</span> <span class="token operator">=</span> <span class="token variable">$tablName</span><span class="token punctuation">;</span>

		<span class="token comment">// &#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x5BF9;&#x8C61;,&#x4FBF;&#x4E8E;&#x94FE;&#x5F0F;&#x8C03;&#x7528;&#x8BE5;&#x5BF9;&#x8C61;&#x7684;&#x5176;&#x5B83;&#x65B9;&#x6CD5;</span>
		<span class="token keyword">return</span> <span class="token this">$this</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x8BBE;&#x7F6E;&#x67E5;&#x8BE2;&#x5B57;&#x6BB5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">field</span><span class="token punctuation">(</span><span class="token variable">$fields</span><span class="token punctuation">)</span>
	<span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">field</span> <span class="token operator">=</span> <span class="token variable">$fields</span><span class="token punctuation">;</span>
		<span class="token keyword">return</span> <span class="token this">$this</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x8BBE;&#x7F6E;&#x67E5;&#x8BE2;&#x6761;&#x4EF6;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">where</span><span class="token punctuation">(</span><span class="token variable">$where</span><span class="token punctuation">)</span>
	<span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">where</span> <span class="token operator">=</span> <span class="token variable">$where</span><span class="token punctuation">;</span>
		<span class="token keyword">return</span> <span class="token this">$this</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x8BBE;&#x7F6E;&#x663E;&#x793A;&#x6570;&#x91CF;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">limit</span><span class="token punctuation">(</span><span class="token variable">$limit</span><span class="token punctuation">)</span>
	<span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">limit</span> <span class="token operator">=</span> <span class="token variable">$limit</span><span class="token punctuation">;</span>
		<span class="token keyword">return</span> <span class="token this">$this</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x521B;&#x5EFA;SQL&#x67E5;&#x8BE2;&#x8BED;&#x53E5;&#x5BF9;&#x8C61;,&#x5E76;&#x8FD4;&#x56DE;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">select</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
	<span class="token punctuation">{</span>
		<span class="token comment">// &#x67E5;&#x8BE2;&#x6761;&#x4EF6;&#x5206;&#x5F00;&#x8BBE;&#x7F6E;, &#x53EF;&#x4EE5;&#x786E;&#x4FDD;&#x94FE;&#x5F0F;&#x65B9;&#x6CD5;&#x72EC;&#x7ACB;</span>
		<span class="token variable">$fields</span> <span class="token operator">=</span> <span class="token function">empty</span><span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">field</span><span class="token punctuation">)</span> <span class="token operator">?</span> <span class="token single-quoted-string string">&apos;*&apos;</span> <span class="token punctuation">:</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">field</span><span class="token punctuation">;</span>
		<span class="token variable">$where</span> <span class="token operator">=</span> <span class="token function">empty</span><span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">where</span><span class="token punctuation">)</span> <span class="token operator">?</span> <span class="token single-quoted-string string">&apos;&apos;</span> <span class="token punctuation">:</span> <span class="token single-quoted-string string">&apos; WHERE &apos;</span><span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">where</span><span class="token punctuation">;</span>
		<span class="token variable">$limit</span> <span class="token operator">=</span> <span class="token function">empty</span><span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">limit</span><span class="token punctuation">)</span> <span class="token operator">?</span> <span class="token single-quoted-string string">&apos;&apos;</span> <span class="token punctuation">:</span> <span class="token single-quoted-string string">&apos; LIMIT &apos;</span><span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">limit</span><span class="token punctuation">;</span>

		<span class="token comment">// &#x63A5;&#x88C5;SQL&#x8BED;&#x53E5;</span>
		<span class="token variable">$sql</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;SELECT &apos;</span><span class="token punctuation">.</span><span class="token variable">$fields</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos; FROM &apos;</span><span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">table</span><span class="token punctuation">.</span> <span class="token variable">$where</span> <span class="token punctuation">.</span> <span class="token variable">$limit</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x9884;&#x5904;&#x7406;&#x67E5;&#x8BE2;</span>
		<span class="token variable">$stmt</span> <span class="token operator">=</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">pdo</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">prepare</span><span class="token punctuation">(</span><span class="token variable">$sql</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">execute</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token keyword">return</span> <span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">fetchAll</span><span class="token punctuation">(</span><span class="token scope">PDO<span class="token punctuation">::</span></span><span class="token constant">FETCH_ASSOC</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</pre><hr>
<h3 class="mume-header" id="-%E5%8D%81%E4%BA%8C-%E8%87%AA%E5%8A%A8%E5%8A%A0%E8%BD%BD">:-: &#x5341;&#x4E8C;&#x3001;&#x81EA;&#x52A8;&#x52A0;&#x8F7D;</h3>

<ul>
<li><code>spl_autoload_register(callback)</code>: &#x901A;&#x8FC7;&#x56DE;&#x8C03;&#x81EA;&#x52A8;&#x52A0;&#x8F7D;&#x5916;&#x90E8;&#x6587;&#x4EF6;</li>
<li><code>__DIR__</code>&#x9B54;&#x672F;&#x5E38;&#x91CF;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token comment">// &#x67E5;&#x770B;&#x5F53;&#x524D;&#x811A;&#x672C;&#x6240;&#x5728;&#x7684;&#x76EE;&#x5F55;</span>
<span class="token keyword">echo</span> <span class="token constant">__DIR__</span><span class="token punctuation">,</span>  <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>

<span class="token keyword">include</span> <span class="token constant">__DIR__</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;/inc/Test1.php&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">include</span> <span class="token constant">__DIR__</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;/inc/Test2.php&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">include</span> <span class="token constant">__DIR__</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;/inc/Test3.php&apos;</span><span class="token punctuation">;</span>
<span class="token shell-comment comment"># &#x5982;&#x679C;&#x5F53;&#x524D;&#x811A;&#x672C;&#x4F7F;&#x7528;&#x4E86;&#x51E0;&#x5341;&#x4E0A;&#x767E;&#x8FD9;&#x6837;&#x7684;&#x7C7B;, &#x4E0A;&#x9762;&#x7684;&#x65B9;&#x5F0F;&#x5C31;&#x5F88;&#x4E0D;&#x4EBA;&#x6027;</span>
<span class="token shell-comment comment"># &#x4F7F;&#x7528;&#x4E0B;&#x9762;&#x7684;&#x81EA;&#x52A8;&#x52A0;&#x8F7D;&#x673A;&#x5236;, &#x4F1A;&#x6839;&#x636E;&#x5BA2;&#x6237;&#x7AEF;&#x8C03;&#x7528;&#x7684;&#x7C7B;, &#x81EA;&#x52A8;&#x8FDB;&#x884C;&#x52A0;&#x8F7D;,&#x6548;&#x7387;&#x9AD8;, &#x4E0D;&#x51FA;&#x9519;</span>
</pre><pre data-role="codeBlock" data-info="php" class="language-php"><span class="token comment">// php&#x6807;&#x51C6;&#x51FD;&#x6570;&#x5E93;&#x4E2D;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;&#x81EA;&#x52A8;&#x52A0;&#x8F7D;&#x6587;&#x4EF6;&#x7684;&#x6CE8;&#x518C;&#x51FD;&#x6570;,&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;&#x8FD9;&#x4E2A;&#x529F;&#x80FD;</span>
<span class="token comment">// &#x8FD9;&#x4E2A;&#x51FD;&#x6570;,&#x5728;&#x5F53;&#x524D;&#x811A;&#x672C;&#x5F15;&#x7528;&#x4E00;&#x4E2A;&#x672A;&#x52A0;&#x8F7D;&#x7684;&#x6587;&#x4EF6;&#x65F6;, &#x4F1A;&#x81EA;&#x52A8;&#x8C03;&#x7528;&#x5B83;&#x7684;&#x56DE;&#x8C03;&#x65B9;&#x6CD5;&#x6765;&#x52A0;&#x8F7D;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;</span>
<span class="token function">spl_autoload_register</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$class</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
	<span class="token comment">//	include __DIR__ . &apos;/inc/Test1.php&apos;;</span>
	<span class="token comment">//	&#x5C06;include&#x4E2D;&#x7684;&#x7C7B;&#x540D;Test1&#x7528;&#x53D8;&#x91CF;&#x66FF;&#x6362;&#x6389;,&#x8FD9;&#x6837;&#x5C31;&#x5B9E;&#x73B0;&#x4E86;&#x6700;&#x7B80;&#x5355;&#x7684;&#x81EA;&#x52A8;&#x52A0;&#x8F7D;</span>
	<span class="token comment">//	&#x540E;&#x9762;&#x6211;&#x4EEC;&#x4F1A;&#x4F7F;&#x7528;&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x6765;&#x5B8C;&#x5584;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;,&#x76EE;&#x524D;&#x5927;&#x5BB6;&#x5148;&#x7406;&#x89E3;&#x5230;&#x8FD9;&#x91CC;&#x5373;&#x53EF;</span>
	<span class="token keyword">include</span> <span class="token constant">__DIR__</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;/inc/&apos;</span><span class="token punctuation">.</span><span class="token variable">$class</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;.php&apos;</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token variable">$test1</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Test1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$test1</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>

<span class="token variable">$test1</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Test2</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$test1</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>

<span class="token variable">$test1</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Test3</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$test1</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><hr>
<h3 class="mume-header" id="-%E5%8D%81%E4%B8%89-%E6%8A%BD%E8%B1%A1%E7%B1%BB">:-: &#x5341;&#x4E09;&#x3001;&#x62BD;&#x8C61;&#x7C7B;</h3>

<ul>
<li><code>abstract</code>: &#x5B9A;&#x4E49;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;/&#x62BD;&#x8C61;&#x7C7B;</li>
<li>&#x7C7B;&#x4E2D;&#x53EA;&#x8981;&#x6709;&#x4E00;&#x4E2A;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;, &#x8BE5;&#x7C7B;&#x5C31;&#x5E94;&#x8BE5;&#x58F0;&#x660E;&#x4E3A;&#x62BD;&#x8C61;&#x7C7B;</li>
<li>&#x62BD;&#x8C61;&#x7C7B;&#x53EA;&#x80FD;&#x88AB;&#x7EE7;&#x627F;,&#x4E0D;&#x80FD;&#x5B9E;&#x4F8B;&#x5316;,&#x5E76;&#x4E14;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x5FC5;&#x987B;&#x5728;&#x5B50;&#x7C7B;&#x5B9E;&#x73B0;</li>
<li>&#x5B9E;&#x73B0;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x7684;&#x5B50;&#x7C7B;&#x65B9;&#x6CD5;&#x53EF;&#x89C1;&#x6027;&#x4E0D;&#x80FD;&#x4F4E;&#x4E8E;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x539F;&#x5B9A;&#x4E49;
<ul>
<li>&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x662F;public, &#x5B50;&#x7C7B;&#x65B9;&#x6CD5;&#x53EA;&#x80FD;&#x662F;public</li>
<li>&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x662F;protected, &#x5B50;&#x7C7B;&#x65B9;&#x6CD5;&#x53EA;&#x80FD;&#x662F;protected/public</li>
</ul>
</li>
</ul>
<blockquote>
<p>&#x4E00;&#x4E2A;&#x62BD;&#x8C61;&#x7C7B;&#x5FC5;&#x987B;&#x88AB;&#x6269;&#x5C55;&#x4E3A;&#x4E00;&#x4E2A;&#x7279;&#x5B9A;&#x7684;&#x7C7B;,&#x6211;&#x4EEC;&#x624D;&#x80FD;&#x521B;&#x5EFA;&#x7C7B;&#x5B9E;&#x4F8B;,&#x4F7F;&#x7528;&#x7C7B;&#x4E2D;&#x529F;&#x80FD;</p>
</blockquote>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">abstract</span> <span class="token keyword">class</span> <span class="token class-name">a</span><span class="token punctuation">{</span>
	<span class="token keyword">public</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x4E0D;&#x7BA1;&#x6709;&#x591A;&#x5C11;&#x4E2A;&#x666E;&#x901A;&#x65B9;&#x6CD5;&#xFF0C;&#x53EA;&#x8981;&#x6709;&#x4E00;&#x4E2A;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#xFF0C;&#x5C31;&#x662F;&#x62BD;&#x8C61;&#x7C7B;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">af</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x4E0D;&#x80FD;&#x6709;&#x5185;&#x5BB9;&#xFF0C;&#x91CC;&#x9762;&#x4E0D;&#x80FD;&#x6709;&#x4EE3;&#x7801;&#xFF0C;{}&#xFF1A;&#x4E0D;&#x80FD;&#x6709;</span>
	<span class="token keyword">abstract</span> <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">aff</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x62BD;&#x8C61;&#x7C7B;&#x4E0D;&#x80FD;&#x5B9E;&#x4F8B;&#x5316;&#xFF0C;&#x4E0D;&#x80FD;new&#xFF0C;&#x53EA;&#x80FD;&#x7EE7;&#x627F;</span>
<span class="token comment">// &#x6211;&#x4EEC;&#x5C31;&#x7528;b&#x7C7B;&#xFF0C;&#x7EE7;&#x627F; a&#x62BD;&#x8C61;&#x7C7B;</span>
<span class="token keyword">class</span> <span class="token class-name">b</span> <span class="token keyword">extends</span> <span class="token class-name">a</span><span class="token punctuation">{</span>
	<span class="token comment">// b&#x7C7B; &#x7EE7;&#x627F; a&#x62BD;&#x8C61;&#x7C7B;&#x540E;&#xFF1A;&#x5FC5;&#x987B;&#x628A;a&#x62BD;&#x8C61;&#x7C7B; &#xFF0C;&#x91CC;&#x9762;&#x7684;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#xFF0C;&#x91CD;&#x65B0;&#x5199;&#x4E00;&#x904D;&#xFF08;&#x5B9E;&#x73B0;&#xFF09;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">aff</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x5B9E;&#x73B0;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x8C03;&#x7528;&#x5B50;&#x7C7B;&#xFF0C;&#x8FDB;&#x884C;&#x5B9E;&#x4F8B;&#x5316;&#xFF0C;&#x7136;&#x540E;&#x8C03;&#x7528;&#x6210;&#x5458;&#x65B9;&#x6CD5;&#x548C;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x3002;</span>
<span class="token variable">$a</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">b</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x6B27;&#x9633;&#x514B;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// &#x4E3A;&#x4EC0;&#x4E48;&#x62BD;&#x8C61;&#x7C7B;&#x91CC;&#x7684;af&#x65B9;&#x6CD5;&#x80FD;&#x8C03;&#x7528;&#x5462;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x662F;&#x666E;&#x901A;&#x65B9;&#x6CD5;&#x3002;</span>
<span class="token variable">$a</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">af</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br/&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x8FD9;&#x91CC;&#x7684;&#x65B9;&#x6CD5;&#x4E3A;&#x4EC0;&#x4E48;&#x80FD;&#x8C03;&#x7528;&#x5462;&#xFF1F; &#x56E0;&#x4E3A;b&#x7C7B;&#xFF0C;&#x7EE7;&#x627F;&#x4E86;a&#x62BD;&#x8C61;&#x7C7B;&#x7684;&#x65B9;&#x6CD5;&#x540E;&#xFF1A;&#x5B9E;&#x73B0;&#x6210;&#x4E3A;&#x666E;&#x901A;&#x7C7B;&#x3002;</span>
<span class="token variable">$a</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">aff</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</pre><ul>
<li>&#x5728;&#x5B9E;&#x9645;&#x5F00;&#x53D1;&#x8FC7;&#x7A0B;&#x4E2D;, &#x901A;&#x5E38;&#x5E76;&#x4E0D;&#x4F1A;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x4E00;&#x4E2A;&#x7236;&#x7C7B;/&#x8D85;&#x7C7B;,&#x800C;&#x662F;&#x5728;&#x7236;&#x7C7B;&#x4E2D;&#x5B9A;&#x4E49;&#x4E00;&#x4E9B;&#x65B9;&#x6CD5;&#x58F0;&#x660E;</li>
<li>&#x5E76;&#x4E14;&#x786E;&#x4FE1;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x80AF;&#x5B9A;&#x662F;&#x4F1A;&#x88AB;&#x5B50;&#x7C7B;&#x91CD;&#x5199;&#x7684;, &#x7236;&#x7C7B;&#x4E2D;&#x6CA1;&#x5FC5;&#x8981;&#x5B9E;&#x73B0;,&#x53EA;&#x8981;&#x7ED9;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x7F16;&#x5199;&#x89C4;&#x8303;&#x5373;&#x53EF;</li>
<li>&#x8FD9;&#x4E2A;&#x89C4;&#x8303;&#x5305;&#x62EC;&#x65B9;&#x6CD5;&#x7684;&#x540D;&#x79F0;, &#x53C2;&#x6570;&#x5217;&#x8868;&#x7B49;,&#x5177;&#x4F53;&#x5B9E;&#x73B0;&#x5C31;&#x5B8C;&#x5168;&#x4EA4;&#x7ED9;&#x5B50;&#x7C7B;&#x53BB;&#x5B8C;&#x6210;&#x4E86;</li>
<li>&#x76F8;&#x5F53;&#x4E8E;&#x516C;&#x53F8;&#x7684;&#x90E8;&#x95E8;&#x4E3B;&#x7BA1;, &#x63A5;&#x53D7;&#x5230;&#x8001;&#x677F;&#x7684;&#x4EFB;&#x52A1;, &#x53EA;&#x628A;&#x5C5E;&#x4E8E;&#x81EA;&#x5DF1;&#x7684;&#x90E8;&#x5206;&#x505A;&#x4E86;, &#x5176;&#x5B83;&#x90E8;&#x5206;, &#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;&#x6807;&#x51C6;&#x4EA4;&#x7ED9;&#x4E0B;&#x5C5E;&#x53BB;&#x5B8C;&#x6210;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">abstract</span> <span class="token keyword">class</span> <span class="token class-name">Person</span><span class="token punctuation">{</span>
	<span class="token keyword">protected</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
	<span class="token keyword">protected</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token operator">=</span><span class="token single-quoted-string string">&apos;peter zhu&apos;</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token variable">$name</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x8BE5;&#x65B9;&#x6CD5;&#x4E0D;&#x9700;&#x8981;&#x91CD;&#x5199;, &#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5B50;&#x7C7B;&#x5BF9;&#x8C61;&#x8BBF;&#x95EE;,&#x5E94;&#x8BE5;&#x8BBE;&#x7F6E;&#x4E3A;public</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x4FEE;&#x6539;&#x5C5E;&#x6027;&#x65B9;&#x6CD5;,&#x8BBE;&#x7F6E;&#x4E3A;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;,&#x4EA4;&#x7ED9;&#x5B50;&#x7C7B;&#x5B9E;&#x73B0;</span>
	<span class="token keyword">abstract</span> <span class="token keyword">protected</span> <span class="token keyword">function</span> <span class="token function">setName</span><span class="token punctuation">(</span><span class="token variable">$value</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token comment">// &#x5F53;&#x5B50;&#x7C7B;&#x7EE7;&#x627F; &#x62BD;&#x8C61;&#x7236;&#x7C7B;&#xFF0C;&#x666E;&#x901A;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#xFF0C;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#xFF0C;&#x5FC5;&#x987B;&#x91CD;&#x65B0;&#x5B9E;&#x73B0;&#x3002;</span>
<span class="token keyword">class</span> <span class="token class-name">Stu</span> <span class="token keyword">extends</span> <span class="token class-name">Person</span><span class="token punctuation">{</span>
	<span class="token comment">// &#x6CE8;&#x610F;: &#x6784;&#x9020;&#x65B9;&#x6CD5;&#x4E0D;&#x4F1A;&#x81EA;&#x52A8;&#x7EE7;&#x627F;, &#x5FC5;&#x987B;&#x624B;&#x52A8;&#x91CD;&#x5199;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token operator">=</span><span class="token single-quoted-string string">&apos;peter zhu&apos;</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token scope"><span class="token keyword">parent</span><span class="token punctuation">::</span></span><span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$name</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// 1&#xFF0C;&#x5B83;&#x7684;&#x7236;&#x7C7B;&#xFF0C;&#x6709;&#x8FD9;&#x4E2A;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#xFF0C;&#x8FD9;&#x91CC;&#x5FC5;&#x987B;&#x91CD;&#x65B0;&#x5199;&#xFF0C;&#x5E26;&#x7740;&#x5177;&#x4F53;&#x7684;&#x4EE3;&#x7801;&#x3002;</span>
	<span class="token comment">// 2&#xFF0C;&#x7C7B;&#x5B9E;&#x4F8B;&#x5316;&#x540E;&#xFF0C;&#x8C03;&#x7528;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x5C31;&#x662F;&#x76F4;&#x63A5;&#x8C03;&#x7528;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x8DDF;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x6CA1;&#x5173;&#x7CFB;&#x3002;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">setName</span><span class="token punctuation">(</span><span class="token variable">$value</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">name</span> <span class="token operator">=</span> <span class="token variable">$value</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token variable">$stu</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Stu</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x732A;&#x54E5;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;php&#x4E2D;&#x6587;&#x7F51;&#x521B;&#x59CB;&#x4EBA;: &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$stu</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x8C03;&#x7528;&#x5B50;&#x7C7B;&#x7684;&#x91CD;&#x5199;&#x7684;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;setName(),&#x6765;&#x8BBE;&#x7F6E;&#x5C5E;&#x6027;</span>
<span class="token variable">$stu</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">setName</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x706D;&#x7EDD;&#x5E08;&#x592A;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 3&#xFF0C;&#x7528;setName&#x4F20;&#x503C;&#x540E;&#xFF0C;&#x503C;&#x7ED9;&#x5230;&#x7236;&#x62BD;&#x8C61;&#x7C7B;&#x91CC;&#x7684;$name,&#x7528;&#x7236;&#x62BD;&#x8C61;&#x7C7B;&#x7684;getName&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x8F93;&#x51FA;&#x4F20;&#x503C;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;php&#x4E2D;&#x6587;&#x7F51;&#x524D;&#x7AEF;&#x8BB2;&#x5E08;: &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$stu</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><ul>
<li>&#x7C7B;&#x4E2D;&#x53EA;&#x8981;&#x6709;&#x4E00;&#x4E2A;&#x6210;&#x5458;&#x8BBE;&#x7F6E;&#x4E3A;&#x62BD;&#x8C61;,&#x8BE5;&#x7C7B;&#x5C31;&#x5FC5;&#x987B;&#x8BBE;&#x7F6E;&#x62BD;&#x8C61;&#x7C7B;</li>
<li>&#x4E00;&#x4E2A;&#x7C7B;&#x4E00;&#x65E6;&#x88AB;&#x8BBE;&#x7F6E;&#x4E3A;&#x62BD;&#x8C61;&#x7C7B;,&#x5C31;&#x5177;&#x5907;&#x4E86;&#x4E8C;&#x4E2A;&#x7279;&#x70B9;:
<ul>
<li>&#x4E0D;&#x80FD;&#x5B9E;&#x4F8B;&#x5316;</li>
<li>&#x7C7B;&#x4E2D;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;,&#x5728;&#x5B50;&#x7C7B;&#x4E2D;&#x5FC5;&#x987B;&#x5B9E;&#x73B0;&#xFF08;&#x5168;&#x90E8;&#xFF09;&#xFF0C;&#x5C31;&#x662F;&#x5B50;&#x7C7B;&#x5FC5;&#x987B;&#x6709;&#x7236;&#x7C7B;&#x7684;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;</li>
</ul>
</li>
<li>&#x6CE8;&#x610F;&#xFF1A;
<ul>
<li>&#x5C5E;&#x6027;&#x8BBE;&#x7F6E;&#x4E3A;&#x62BD;&#x8C61;&#x65E0;&#x610F;&#x4E49;, &#x62BD;&#x8C61;&#x4EC5;&#x9488;&#x5BF9;&#x65B9;&#x6CD5;&#xFF0C;&#x7C7B;</li>
<li>&#x5B50;&#x7C7B;&#x7684;&#x6210;&#x5458;&#x53EF;&#x89C1;&#x6027;&#x5FC5;&#x987B;&#x7B49;&#x4E8E;&#x6216;&#x9AD8;&#x4E8E;&#x6240;&#x7EE7;&#x627F;&#x7684;&#x62BD;&#x8C61;&#x7C7B;&#x6210;&#x5458;&#x53EF;&#x89C1;&#x6027;,&#x4F8B;&#x5982;&#x62BD;&#x8C61;&#x7C7B;&#x662F;proteced,&#x5B50;&#x7C7B;&#x53EF;&#x4EE5;&#x662F;protected/pulic</li>
<li>&#x5B50;&#x7C7B;&#x91CD;&#x5199;&#x7684;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x53EF;&#x89C1;&#x6027;,&#x7A76;&#x7ADF;&#x7528;protected/pulic, &#x8981;&#x770B;&#x8FD9;&#x4E2A;&#x5B50;&#x7C7B;&#x662F;&#x6700;&#x7EC8;&#x88AB;&#x5BA2;&#x6237;&#x7AEF;&#x8BBF;&#x95EE;,&#x5982;&#x679C;&#x662F;&#x5C31;public,&#x5982;&#x679C;&#x4E0D;&#x662F;protected</li>
</ul>
</li>
<li>&#x7EA7;&#x522B;&#xFF1A;
<ul>
<li>public            &#x7EA7;&#x522B;&#x6700;&#x9AD8;&#xFF1A; A</li>
<li>protected        &#x7EA7;&#x522B;&#x4E2D;&#x7B49;&#xFF1A; B</li>
<li>private            &#x7EA7;&#x522B;&#x6700;&#x4F4E;&#xFF1A; C</li>
</ul>
</li>
</ul>
<hr>
<h3 class="mume-header" id="-%E5%8D%81%E4%B8%89-%E6%8E%A5%E5%8F%A3">:-: &#x5341;&#x4E09;&#x3001;&#x63A5;&#x53E3;</h3>

<ul>
<li><code>interface</code>: &#x6307;&#x5B9A;&#x67D0;&#x4E2A;&#x7C7B;&#x5FC5;&#x987B;&#x5B9E;&#x73B0;&#x7684;&#x65B9;&#x6CD5;,&#x4F46;&#x4E0D;&#x9700;&#x8981;&#x5B9A;&#x4E49;&#x65B9;&#x6CD5;&#x7684;&#x5177;&#x4F53;&#x5B9E;&#x73B0;&#x8FC7;&#x7A0B;</li>
<li>&#x63A5;&#x53E3;&#x4E2D;&#x4EC5;&#x5141;&#x8BB8;&#x51FA;&#x73B0;: &#x65B9;&#x6CD5;&#x4E0E;&#x5E38;&#x91CF;</li>
<li>&#x63A5;&#x53E3;&#x7684;&#x65B9;&#x6CD5;&#x53EF;&#x89C1;&#x6027;&#x5FC5;&#x987B;&#x662F;: public</li>
<li>&#x63A5;&#x53E3;&#x7684;&#x65B9;&#x6CD5;&#x4F53;&#x5FC5;&#x987B;&#x662F;&#x7A7A;&#x7684;</li>
<li>&#x63A5;&#x53E3;&#x662F;&#x7C7B;&#x7684;&#x4EE3;&#x7801;&#x6A21;&#x677F;, &#x53EF;&#x4EE5;&#x50CF;&#x7C7B;&#x4E00;&#x6837;&#x6709;&#x7236;&#x5B50;&#x7EE7;&#x627F;&#x5173;&#x7CFB;,&#x4F8B;&#x5982;&#x7236;&#x63A5;&#x53E3;, &#x5B50;&#x63A5;&#x53E3;</li>
<li><code>implements</code>: &#x7C7B;&#x5B9E;&#x73B0;&#x63A5;&#x53E3;&#x7684;&#x5173;&#x952E;&#x5B57;</li>
<li>&#x5982;&#x679C;&#x4EC5;&#x662F;&#x90E8;&#x5206;&#x5B9E;&#x73B0;&#x63A5;&#x53E3;&#x4E2D;&#x7684;&#x65B9;&#x6CD5;, &#x8BF7;&#x7528;&#x4E00;&#x4E2A;&#x62BD;&#x8C61;&#x7C7B;&#x6765;&#x5B9E;&#x73B0;&#x5B83;</li>
<li>&#x63A5;&#x53E3;&#x4E2D;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x5FC5;&#x987B;&#x5168;&#x662F;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;</li>
<li>&#x62BD;&#x8C61;&#x548C;&#x63A5;&#x53E3;&#x533A;&#x522B;&#xFF1A;
<ul>
<li>&#x62BD;&#x8C61;&#x53EF;&#x4EE5;&#x6709;&#x666E;&#x901A;&#x65B9;&#x6CD5;&#xFF0C;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x3002;</li>
<li>&#x63A5;&#x53E3;&#x4E0D;&#x53EF;&#x4EE5;&#x6709;&#x666E;&#x901A;&#x65B9;&#x6CD5;&#xFF0C;&#x4E0D;&#x53EF;&#x4EE5;&#x6709;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x3002;</li>
</ul>
</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">interface</span> <span class="token class-name">iVehicle</span><span class="token punctuation">{</span>
	<span class="token keyword">const</span> <span class="token constant">COUNTRY</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x4E2D;&#x56FD;&apos;</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x9A71;&#x52A8;&#x65B9;&#x5F0F;: &#x6C7D;&#x8F66;, &#x65B0;&#x80FD;&#x6E90;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">setFuel</span><span class="token punctuation">(</span><span class="token variable">$fuel</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x7528;&#x9014;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">setPurpose</span><span class="token punctuation">(</span><span class="token variable">$purpose</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token comment">// Car &#x7C7B; &#x5B9E;&#x73B0;&#x4E86;&#x63A5;&#x53E3;:  iVehicle&#xFF0C;&#x5173;&#x952E;&#x8BCD;&#xFF1A;implements</span>
<span class="token comment">// &#x62BD;&#x8C61;&#x7C7B; &#x5B9E;&#x73B0;&#x63A5;&#x53E3;:  iVehicle&#xFF0C;&#x5173;&#x952E;&#x8BCD;&#xFF1A;implements</span>
<span class="token comment">// &#x63A5;&#x53E3; &#x53EF;&#x4EE5; &#x7EE7;&#x627F;&#x63A5;&#x53E3;&#xFF1A;extends</span>
<span class="token comment">// &#x7C7B; &#x53EF;&#x4EE5; &#x540C;&#x65F6; &#x7EE7;&#x627F; &#x548C;&#x5B9E;&#x73B0;(&#x5148;&#x7EE7;&#x627F;&#xFF0C;&#x5728;&#x5B9E;&#x73B0;)</span>
<span class="token comment">// &#x53EF;&#x4EE5;&#x5B9E;&#x73B0;&#x591A;&#x4E2A;&#x63A5;&#x53E3;&#xFF0C;&#x7528;&#x9017;&#x53F7;&#x9694;&#x5F00;</span>
<span class="token keyword">class</span> <span class="token class-name">Car</span> <span class="token keyword">implements</span> <span class="token class-name">iVehicle</span><span class="token punctuation">{</span>
	<span class="token keyword">public</span> <span class="token variable">$fuel</span><span class="token punctuation">;</span>
	<span class="token keyword">public</span> <span class="token variable">$purpose</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$fuel</span><span class="token operator">=</span><span class="token single-quoted-string string">&apos;&#x6C7D;&#x6CB9;&apos;</span><span class="token punctuation">,</span> <span class="token variable">$purpose</span><span class="token operator">=</span><span class="token single-quoted-string string">&apos;&#x5BB6;&#x7528;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">fuel</span> <span class="token operator">=</span> <span class="token variable">$fuel</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">purpose</span> <span class="token operator">=</span> <span class="token variable">$purpose</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x5FC5;&#x987B;&#x5B9E;&#x73B0;&#x7684;&#x63A5;&#x53E3;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">setFuel</span><span class="token punctuation">(</span><span class="token variable">$fuel</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">fuel</span> <span class="token operator">=</span> <span class="token variable">$fuel</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x5FC5;&#x987B;&#x5B9E;&#x73B0;&#x7684;&#x63A5;&#x53E3;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">setPurpose</span><span class="token punctuation">(</span><span class="token variable">$purpose</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">purpose</span> <span class="token operator">=</span> <span class="token variable">$purpose</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x7C7B;&#x4E2D;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">fuel</span> <span class="token punctuation">.</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">purpose</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&#x8F66; &lt;br&gt;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token comment">// &#x5BA2;&#x6237;&#x7AEF;&#x4EE3;&#x7801;</span>
<span class="token variable">$car</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Car</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$car</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token variable">$car</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">setFuel</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x65B0;&#x80FD;&#x6E90;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token variable">$car</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">setPurpose</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x516C;&#x4EA4;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$car</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>
</pre><blockquote>
<p>&#x5982;&#x679C;&#x6682;&#x65F6;&#x53EA;&#x80FD;&#x5B9E;&#x73B0;&#x63A5;&#x53E3;&#x4E2D;&#x7684;&#x90E8;&#x5206;&#x65B9;&#x6CD5;, &#x53EF;&#x4EE5;&#x7528;&#x4E00;&#x4E2A;&#x62BD;&#x8C61;&#x6765;&#x5B9E;&#x73B0;&#x8FD9;&#x4E2A;&#x63A5;&#x53E3;</p>
</blockquote>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">interface</span> <span class="token class-name">iVehicle</span><span class="token punctuation">{</span>
	<span class="token keyword">const</span> <span class="token constant">COUNTRY</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&#x4E2D;&#x56FD;&apos;</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x9A71;&#x52A8;&#x65B9;&#x5F0F;: &#x6C7D;&#x8F66;, &#x65B0;&#x80FD;&#x6E90;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">setFuel</span><span class="token punctuation">(</span><span class="token variable">$fuel</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x7528;&#x9014;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">setPurpose</span><span class="token punctuation">(</span><span class="token variable">$purpose</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">abstract</span> <span class="token keyword">class</span> <span class="token class-name">Auto</span> <span class="token keyword">implements</span> <span class="token class-name">iVehicle</span><span class="token punctuation">{</span>
	<span class="token keyword">public</span> <span class="token variable">$fuel</span><span class="token punctuation">;</span>
	<span class="token comment">// &#x53EA;&#x5B9E;&#x73B0;&#x63A5;&#x53E3;&#x4E2D;&#x7684;setFuel()&#x65B9;&#x6CD5;, &#x53E6;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#x5E76;&#x672A;&#x5B9E;&#x73B0;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">setFuel</span><span class="token punctuation">(</span><span class="token variable">$fuel</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">fuel</span> <span class="token operator">=</span> <span class="token variable">$fuel</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token comment">// &#x518D;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x7C7B;,&#x6765;&#x7EE7;&#x627F;&#x6269;&#x5C55;&#x8FD9;&#x4E2A;&#x62BD;&#x8C61;&#x7C7B;  Auto</span>
<span class="token keyword">class</span> <span class="token class-name">Car1</span> <span class="token keyword">extends</span> <span class="token class-name">Auto</span><span class="token punctuation">{</span>
	<span class="token keyword">public</span> <span class="token variable">$purpose</span><span class="token punctuation">;</span>

	<span class="token comment">// &#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$fuel</span><span class="token operator">=</span><span class="token single-quoted-string string">&apos;&#x6C7D;&#x6CB9;&apos;</span><span class="token punctuation">,</span> <span class="token variable">$purpose</span><span class="token operator">=</span><span class="token single-quoted-string string">&apos;&#x5BB6;&#x7528;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">fuel</span> <span class="token operator">=</span> <span class="token variable">$fuel</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">purpose</span> <span class="token operator">=</span> <span class="token variable">$purpose</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x539F;&#x6765;&#x5728;&#x63A5;&#x53E3;&#x4E2D;&#x58F0;&#x660E;&#x7684;,&#x5728;&#x5B83;&#x7EE7;&#x627F;&#x7684;&#x62BD;&#x8C61;&#x7C7B;&#x4E2D;&#x5E76;&#x6CA1;&#x6709;&#x58F0;&#x660E;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">setPurpose</span><span class="token punctuation">(</span><span class="token variable">$purpose</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">purpose</span> <span class="token operator">=</span> <span class="token variable">$purpose</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token comment">// &#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x65B9;&#x6CD5;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">return</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">fuel</span> <span class="token punctuation">.</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">purpose</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;&#x8F66; &lt;br&gt;&apos;</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token comment">// &#x5BA2;&#x6237;&#x7AEF;&#x4EE3;&#x7801;</span>

<span class="token variable">$car1</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Car1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$car1</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token variable">$car1</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">setFuel</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x5929;&#x7136;&#x6C14;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token variable">$car1</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">setPurpose</span><span class="token punctuation">(</span><span class="token single-quoted-string string">&apos;&#x5BB6;&#x7528;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$car1</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">getInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</pre><ul>
<li>&#x603B;&#x7ED3;&#xFF1A;
<ul>
<li>&#x5982;&#x679C;&#x4E0D;&#x80FD;&#x5C06;&#x63A5;&#x53E3;&#x4E2D;&#x65B9;&#x6CD5;&#x5168;&#x90E8;&#x5B9E;&#x73B0;&#x5C31;&#x7528;&#x62BD;&#x8C61;&#x7C7B;&#x6765;&#x5B9E;&#x73B0;&#x5B83;</li>
<li>&#x5426;&#x5219;,&#x5C31;&#x5FC5;&#x987B;&#x5168;&#x90E8;&#x628A;&#x63A5;&#x53E3;&#x4E2D;&#x65B9;&#x6CD5;&#x5168;&#x90E8;&#x5B9E;&#x73B0;</li>
</ul>
</li>
</ul>
<hr>
<h3 class="mume-header" id="-%E5%8D%81%E5%9B%9B-%E6%8E%A5%E5%8F%A3%E6%8C%89%E5%AE%9E%E6%88%98%E6%A1%88%E4%BE%8B">:-: &#x5341;&#x56DB;&#x3001;&#x63A5;&#x53E3;&#x6309;&#x5B9E;&#x6218;&#x6848;&#x4F8B;</h3>

<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token comment">// &#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;,&#x5B9E;&#x73B0;&#x6570;&#x636E;&#x5E93;&#x5E38;&#x7528;&#x64CD;&#x4F5C;:&#x589E;&#x5220;&#x6539;&#x67E5;</span>
<span class="token keyword">interface</span> <span class="token class-name">iCurd</span>
<span class="token punctuation">{</span>
	<span class="token comment">// &#x589E;&#x52A0;&#x6570;&#x636E;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">create</span><span class="token punctuation">(</span><span class="token variable">$data</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

	<span class="token comment">// &#x8BFB;&#x53D6;&#x6570;&#x636E;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">read</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

	<span class="token comment">// &#x66F4;&#x65B0;&#x6570;&#x636E;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">update</span><span class="token punctuation">(</span><span class="token variable">$data</span><span class="token punctuation">,</span> <span class="token variable">$where</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

	<span class="token comment">// &#x5220;&#x9664;&#x6570;&#x636E;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">delete</span><span class="token punctuation">(</span><span class="token variable">$where</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token comment">// &#x521B;&#x5EFA;Db&#x7C7B;, &#x5B9E;&#x73B0;iCurd&#x63A5;&#x53E3;,&#x5B8C;&#x6210;&#x57FA;&#x672C;&#x7684;&#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;</span>
<span class="token keyword">class</span> <span class="token class-name">Db</span> <span class="token keyword">implements</span> <span class="token class-name">iCurd</span><span class="token punctuation">{</span>
	<span class="token comment">//&#x6570;&#x636E;&#x5E93;&#x7684;&#x8FDE;&#x63A5;&#x5BF9;&#x8C61;</span>
	<span class="token keyword">protected</span> <span class="token variable">$pdo</span> <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>

	<span class="token comment">// &#x6570;&#x636E;&#x8868;&#x540D;</span>
	<span class="token keyword">protected</span> <span class="token variable">$table</span><span class="token punctuation">;</span>

	<span class="token comment">// &#x6784;&#x9020;&#x65B9;&#x6CD5;: &#x8FDE;&#x63A5;&#x6570;&#x636E;&#x5E93;,&#x5E76;&#x8BBE;&#x7F6E;&#x9ED8;&#x8BA4;&#x6570;&#x636E;&#x8868;&#x540D;&#x79F0;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$dsn</span><span class="token punctuation">,</span> <span class="token variable">$user</span><span class="token punctuation">,</span> <span class="token variable">$password</span><span class="token punctuation">,</span> <span class="token variable">$table</span><span class="token operator">=</span><span class="token single-quoted-string string">&apos;staff&apos;</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">pdo</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">PDO</span><span class="token punctuation">(</span><span class="token variable">$dsn</span><span class="token punctuation">,</span> <span class="token variable">$user</span><span class="token punctuation">,</span> <span class="token variable">$password</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">table</span> <span class="token operator">=</span> <span class="token variable">$table</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token comment">// &#x8BFB;&#x53D6;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">read</span><span class="token punctuation">(</span><span class="token variable">$fields</span><span class="token operator">=</span><span class="token single-quoted-string string">&apos;*&apos;</span><span class="token punctuation">,</span> <span class="token variable">$where</span><span class="token operator">=</span><span class="token single-quoted-string string">&apos;&apos;</span><span class="token punctuation">,</span> <span class="token variable">$limit</span><span class="token operator">=</span><span class="token single-quoted-string string">&apos;0, 5&apos;</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x8BBE;&#x7F6E;&#x67E5;&#x8BE2;&#x6761;&#x4EF6;</span>
		<span class="token variable">$where</span> <span class="token operator">=</span> <span class="token function">empty</span><span class="token punctuation">(</span><span class="token variable">$where</span><span class="token punctuation">)</span> <span class="token operator">?</span> <span class="token single-quoted-string string">&apos;&apos;</span> <span class="token punctuation">:</span> <span class="token single-quoted-string string">&apos; WHERE &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$where</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x8BBE;&#x7F6E;&#x663E;&#x793A;&#x6570;&#x91CF;</span>
		<span class="token variable">$limit</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos; LIMIT &apos;</span> <span class="token punctuation">.</span> <span class="token variable">$limit</span><span class="token punctuation">;</span>

		<span class="token comment">// &#x9884;&#x5904;&#x7406;&#x67E5;&#x8BE2;&#x64CD;&#x4F5C;</span>
		<span class="token variable">$sql</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;SELECT &apos;</span><span class="token punctuation">.</span><span class="token variable">$fields</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos; FROM &apos;</span><span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">table</span><span class="token punctuation">.</span><span class="token variable">$where</span><span class="token punctuation">.</span><span class="token variable">$limit</span><span class="token punctuation">;</span>
		<span class="token variable">$stmt</span> <span class="token operator">=</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">pdo</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">prepare</span><span class="token punctuation">(</span><span class="token variable">$sql</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">execute</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

		<span class="token comment">// &#x8FD4;&#x56DE;&#x4E8C;&#x7EF4;&#x6570;&#x7EC4;&#x8868;&#x793A;&#x7684;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x96C6;</span>
		<span class="token keyword">return</span> <span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">fetchAll</span><span class="token punctuation">(</span><span class="token scope">PDO<span class="token punctuation">::</span></span><span class="token constant">FETCH_ASSOC</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token comment">// &#x65B0;&#x589E;, &#x53C2;&#x6570;&#x662F;&#x6570;&#x7EC4;: &#x65B0;&#x8BB0;&#x5F55;&#x7684;&#x952E;&#x503C;&#x5BF9;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">create</span><span class="token punctuation">(</span><span class="token variable">$data</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x5B57;&#x6BB5;&#x5217;&#x8868;</span>
		<span class="token variable">$fields</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos; (name,age,sex,position,mobile,hiredate)&apos;</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x503C;&#x5217;&#x8868;</span>
		<span class="token variable">$values</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;(:name,:age,:sex,:position,:mobile,:hiredate)&apos;</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x521B;&#x5EFA;SQL&#x8BED;&#x53E5;</span>
		<span class="token variable">$sql</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;INSERT INTO &apos;</span><span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">table</span><span class="token punctuation">.</span><span class="token variable">$fields</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos; VALUES &apos;</span><span class="token punctuation">.</span><span class="token variable">$values</span><span class="token punctuation">;</span>

		<span class="token comment">// &#x9884;&#x5904;&#x7406;&#x6267;&#x884C;&#x65B0;&#x589E;&#x64CD;&#x4F5C;</span>
		<span class="token variable">$stmt</span> <span class="token operator">=</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">pdo</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">prepare</span><span class="token punctuation">(</span><span class="token variable">$sql</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">execute</span><span class="token punctuation">(</span><span class="token variable">$data</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

		<span class="token comment">// &#x8FD4;&#x56DE;&#x65B0;&#x589E;&#x6570;&#x91CF;, &#x65B0;&#x589E;&#x8BB0;&#x5F55;&#x7684;ID&#x7EC4;&#x6210;&#x7684;&#x6570;&#x7EC4;</span>
		<span class="token keyword">return</span> <span class="token punctuation">[</span>
			<span class="token single-quoted-string string">&apos;count&apos;</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">rowCount</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
			<span class="token single-quoted-string string">&apos;id&apos;</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">pdo</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">lastInsertId</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
		<span class="token punctuation">]</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token comment">// &#x66F4;&#x65B0;, &#x4E3A;&#x4E86;&#x6570;&#x636E;&#x5B89;&#x5168;, &#x4E0D;&#x5141;&#x8BB8;&#x65E0;&#x6761;&#x4EF6;&#x66F4;&#x65B0;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">update</span><span class="token punctuation">(</span><span class="token variable">$data</span><span class="token punctuation">,</span> <span class="token variable">$where</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x96BE;&#x70B9;&#x5728;&#x4E8E;SET &#x53C2;&#x6570;&#x7684;&#x5904;&#x7406;&#x4E0A;,&#x5229;&#x7528;&#x4F20;&#x5165;&#x7684;$data&#x6570;&#x7EC4;,&#x8FDB;&#x884C;&#x62C6;&#x88C5;</span>

		<span class="token comment">// &#x83B7;&#x53D6;&#x6570;&#x7EC4;&#x7684;&#x952E;&#x540D;&#x7EC4;&#x6210;&#x7684;&#x6570;&#x7EC4;</span>
		<span class="token variable">$keyArr</span> <span class="token operator">=</span> <span class="token function">array_keys</span><span class="token punctuation">(</span><span class="token variable">$data</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token variable">$set</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;&apos;</span><span class="token punctuation">;</span>
		<span class="token comment">// &#x904D;&#x5386;&#x952E;&#x540D;&#x8868;&#x793A;&#x7684;&#x5B57;&#x6BB5;&#x5217;&#x8868;,&#x62FC;&#x88C5;&#x9884;&#x5904;&#x7406;&#x9700;&#x8981;&#x7684;sql&#x8BED;&#x53E5;,&#x6CE8;&#x610F;&#x5360;&#x7B26;&#x7B26;&#x7684;&#x8868;&#x793A;</span>
		<span class="token keyword">foreach</span> <span class="token punctuation">(</span><span class="token variable">$keyArr</span> <span class="token keyword">as</span> <span class="token variable">$value</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
			<span class="token variable">$set</span> <span class="token punctuation">.</span><span class="token operator">=</span> <span class="token variable">$value</span> <span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos; = :&apos;</span> <span class="token punctuation">.</span><span class="token variable">$value</span><span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos;, &apos;</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span>
		<span class="token comment">// &#x53BB;&#x6389;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x9017;&#x53F7;, &#x6CE8;&#x610F;&#x6BCF;&#x4E2A;&#x9017;&#x53F7;&#x540E;&#x6709;&#x4E00;&#x4E2A;&#x7A7A;&#x683C;,&#x53BB;&#x9664;&#x65F6;&#x4E5F;&#x8981;&#x5E26;&#x4E0A;&#x8FD9;&#x4E2A;&#x7A7A;&#x683C;</span>
		<span class="token variable">$set</span> <span class="token operator">=</span> <span class="token function">rtrim</span><span class="token punctuation">(</span><span class="token variable">$set</span><span class="token punctuation">,</span><span class="token single-quoted-string string">&apos;, &apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

		<span class="token comment">// &#x9884;&#x5904;&#x7406;&#x6267;&#x884C;&#x66F4;&#x65B0;&#x64CD;&#x4F5C;</span>
		<span class="token variable">$sql</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;UPDATE &apos;</span><span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">table</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos; SET &apos;</span><span class="token punctuation">.</span><span class="token variable">$set</span> <span class="token punctuation">.</span><span class="token single-quoted-string string">&apos; WHERE &apos;</span> <span class="token punctuation">.</span><span class="token variable">$where</span><span class="token punctuation">;</span>
		<span class="token variable">$stmt</span> <span class="token operator">=</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">pdo</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">prepare</span><span class="token punctuation">(</span><span class="token variable">$sql</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">execute</span><span class="token punctuation">(</span><span class="token variable">$data</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

		<span class="token comment">// &#x8FD4;&#x56DE;&#x88AB;&#x66F4;&#x65B0;&#x7684;&#x8BB0;&#x5F55;&#x6570;&#x91CF;</span>
		<span class="token keyword">return</span> <span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">rowCount</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token comment">// &#x5220;&#x9664;: &#x4E0E;&#x66F4;&#x65B0;&#x4E00;&#x6837;, &#x8FD9;&#x4E5F;&#x662F;&#x5371;&#x9669;&#x7684;&#x5199;&#x64CD;&#x4F5C;, &#x4E0D;&#x5141;&#x8BB8;&#x65E0;&#x6761;&#x4EF6;&#x5220;&#x9664;</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">delete</span><span class="token punctuation">(</span><span class="token variable">$where</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// &#x9884;&#x5904;&#x7406;&#x6267;&#x884C;&#x5220;&#x9664;&#x64CD;&#x4F5C;</span>
		<span class="token variable">$sql</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;DELETE FROM &apos;</span><span class="token punctuation">.</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">table</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos; WHERE &apos;</span><span class="token punctuation">.</span><span class="token variable">$where</span><span class="token punctuation">;</span>
		<span class="token variable">$stmt</span> <span class="token operator">=</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">pdo</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">prepare</span><span class="token punctuation">(</span><span class="token variable">$sql</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">execute</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token keyword">return</span> <span class="token variable">$stmt</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">rowCount</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token comment">// &#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x6D4B;&#x8BD5;&#x4EE3;&#x7801;</span>
<span class="token comment">// &#x5B9E;&#x4F8B;&#x5316;Db&#x7C7B;</span>
<span class="token variable">$dsn</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;mysql:host=localhost;dbname=ouyangke&apos;</span><span class="token punctuation">;</span>
<span class="token variable">$user</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;root&apos;</span><span class="token punctuation">;</span>
<span class="token variable">$password</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;root&apos;</span><span class="token punctuation">;</span>
<span class="token variable">$db</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Db</span><span class="token punctuation">(</span><span class="token variable">$dsn</span><span class="token punctuation">,</span> <span class="token variable">$user</span><span class="token punctuation">,</span> <span class="token variable">$password</span><span class="token punctuation">)</span><span class="token punctuation">;</span>


<span class="token comment">// &#x904D;&#x5386;&#x8BFB;&#x53D6;</span>
<span class="token keyword">foreach</span> <span class="token punctuation">(</span><span class="token variable">$db</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">read</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">as</span> <span class="token variable">$item</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
	<span class="token function">print_r</span><span class="token punctuation">(</span><span class="token variable">$item</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;br&gt;&apos;</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>

<span class="token comment">// &#x65B0;&#x589E;&#x6570;&#x636E;</span>
<span class="token variable">$data</span> <span class="token operator">=</span> <span class="token punctuation">[</span>
	<span class="token single-quoted-string string">&apos;name&apos;</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token single-quoted-string string">&apos;&#x90ED;&#x9756;&apos;</span><span class="token punctuation">,</span>
	<span class="token single-quoted-string string">&apos;age&apos;</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token number">30</span><span class="token punctuation">,</span>
	<span class="token single-quoted-string string">&apos;sex&apos;</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token number">1</span><span class="token punctuation">,</span>
	<span class="token single-quoted-string string">&apos;position&apos;</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token single-quoted-string string">&apos;&#x91D1;&#x5200;&#x9A78;&#x9A6C;&apos;</span><span class="token punctuation">,</span>
	<span class="token single-quoted-string string">&apos;mobile&apos;</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token single-quoted-string string">&apos;13666668888&apos;</span><span class="token punctuation">,</span>
	<span class="token single-quoted-string string">&apos;hiredate&apos;</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token function">time</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token variable">$res</span> <span class="token operator">=</span> <span class="token variable">$db</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">create</span><span class="token punctuation">(</span><span class="token variable">$data</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x6210;&#x529F;&#x65B0;&#x589E;&apos;</span><span class="token punctuation">.</span><span class="token variable">$res</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;count&apos;</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token single-quoted-string string">&apos;&#x6761;&#x8BB0;&#x5F55;,&#x6700;&#x65B0;&#x8BB0;&#x5F55;&#x7684;&#x4E3B;&#x952E;ID&#x662F;: &apos;</span><span class="token punctuation">.</span><span class="token variable">$res</span><span class="token punctuation">[</span><span class="token single-quoted-string string">&apos;id&apos;</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>

<span class="token comment">// &#x66F4;&#x65B0;&#x8BB0;&#x5F55;</span>
<span class="token variable">$data</span> <span class="token operator">=</span> <span class="token punctuation">[</span>
	<span class="token single-quoted-string string">&apos;age&apos;</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token number">5</span><span class="token punctuation">,</span>
	<span class="token single-quoted-string string">&apos;position&apos;</span><span class="token operator">=</span><span class="token operator">&gt;</span><span class="token single-quoted-string string">&apos;&#x6297;&#x91D1;&#x82F1;&#x96C4;&apos;</span>
<span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token variable">$where</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;id = 5&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x6210;&#x529F;&#x66F4;&#x65B0;&#x4E86;: &apos;</span> <span class="token punctuation">.</span><span class="token variable">$db</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">update</span><span class="token punctuation">(</span><span class="token variable">$data</span><span class="token punctuation">,</span> <span class="token variable">$where</span><span class="token punctuation">)</span><span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos; &#x6761;&#x8BB0;&#x5F55;&apos;</span><span class="token punctuation">;</span>

<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&lt;hr&gt;&apos;</span><span class="token punctuation">;</span>

<span class="token comment">// &#x5220;&#x9664;&#x8BB0;&#x5F55;</span>
<span class="token variable">$where</span> <span class="token operator">=</span> <span class="token single-quoted-string string">&apos;id = 5&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token single-quoted-string string">&apos;&#x6210;&#x529F;&#x66F4;&#x65B0;&#x4E86;: &apos;</span> <span class="token punctuation">.</span><span class="token variable">$db</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">delete</span><span class="token punctuation">(</span><span class="token variable">$where</span><span class="token punctuation">)</span><span class="token punctuation">.</span> <span class="token single-quoted-string string">&apos; &#x6761;&#x8BB0;&#x5F55;&apos;</span><span class="token punctuation">;</span>
</pre><hr>
<h3 class="mume-header" id="-%E5%8D%81%E4%BA%94-%E5%90%8E%E6%9C%9F%E9%9D%99%E6%80%81%E7%BB%91%E5%AE%9A">:-: &#x5341;&#x4E94;&#x3001;&#x540E;&#x671F;&#x9759;&#x6001;&#x7ED1;&#x5B9A;</h3>

<ul>
<li>&#x540E;&#x671F;&#x9759;&#x6001;&#x7ED1;&#x5B9A;,&#x4E5F;&#x53EB;&quot;&#x5EF6;&#x8FDF;&#x9759;&#x6001;&#x7ED1;&#x5B9A;&quot;</li>
<li>&#x8FD9;&#x4E2A;&#x6280;&#x672F;&#x5E94;&#x7528;&#x5728;&#x9759;&#x6001;&#x7EE7;&#x627F;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x73AF;&#x5883;&#x4E2D;,&#x7528;&#x4E8E;&#x52A8;&#x6001;&#x8C03;&#x7528;&#x88AB;&#x91CD;&#x5199;&#x7684;&#x65B9;&#x6CD5;</li>
<li>&#x8C03;&#x7528;&#x88AB;&#x91CD;&#x5199;&#x7684;&#x9759;&#x6001;&#x65B9;&#x6CD5;&#x4F7F;&#x7528;&#x5173;&#x952E;&#x5B57;: <code>static</code> &#x52A0;&#x4E0A;&quot;&#x8303;&#x56F4;&#x89E3;&#x6790;&#x7B26;&quot;<code>::</code></li>
<li><code>::</code> &#x8303;&#x56F4;&#x89E3;&#x6790;&#x7B26;&#x7684;&#x4F7F;&#x7528;&#x573A;&#x666F;
<ul>
<li>&#x8BBF;&#x95EE;&#x7C7B;&#x65B9;&#x6CD5;&#x4E0E;&#x7C7B;&#x5E38;&#x91CF;</li>
<li>&#x8BBF;&#x95EE;&#x88AB;&#x91CD;&#x5199;&#x7684;&#x5BF9;&#x8C61;&#x6216;&#x7C7B;&#x65B9;&#x6CD5;</li>
</ul>
</li>
<li>static&#x5173;&#x952E;&#x5B57;&#x7528;&#x6765;&#x8C03;&#x7528;&#x91CD;&#x5199;&#x65B9;&#x6CD5;&#x7684;&#x65F6;&#x5019;,&#x53EF;&#x4EE5;&#x52A8;&#x6001;&#x7684;&#x7ED1;&#x5B9A;&#x5F53;&#x524D;&#x8C03;&#x7528;&#x7684;&#x7C7B;</li>
</ul>
<pre data-role="codeBlock" data-info="php" class="language-php"><span class="token keyword">class</span> <span class="token class-name">A</span><span class="token punctuation">{</span>
	<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">function</span> <span class="token function">who</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token number">111</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
	<span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token comment">// self::who();	// &#x731C;&#x4E00;&#x4E0B;&#xFF0C;&#x662F;&#x8C03;&#x7528;&#x5B83;&#x81EA;&#x5DF1;&#x7684;who&#xFF0C;&#x8FD8;&#x662F;&#x5B50;&#x7C7B;&#x7684;who&#x5462;&#xFF1F;</span>

		<span class="token comment">// &#x90A3;&#x4E48;&#x5982;&#x4F55;&#x5728;&#x8FD9;&#x79CD;&#x9759;&#x6001;&#x7EE7;&#x627F;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x73AF;&#x5883;&#x4E2D;, &#x9759;&#x6001;&#x8C03;&#x7528;&#x7C7B;&#x4E2D;&#x65B9;&#x6CD5;&#x7684;&#x65F6;&#x5019;,&#x6B63;&#x786E;&#x8BC6;&#x522B;&#x8C03;&#x7528;&#x8005;&#x5462;?</span>
		<span class="token comment">// &#x53EF;&#x4EE5;&#x5C06;self &#x5173;&#x952E;&#x5B57;&#x6539;&#x4E3A;: static ,</span>
		<span class="token comment">// &#x6CE8;&#x610F;: static &#x9664;&#x4E86;&#x53EF;&#x4EE5;&#x7528;&#x5728;&#x9759;&#x6001;&#x65B9;&#x6CD5;&#x4E2D;, &#x4E5F;&#x53EF;&#x4EE5;&#x7528;&#x5728;&#x666E;&#x901A;&#x5BF9;&#x8C61;&#x65B9;&#x6CD5;&#x4E2D;</span>
		<span class="token scope"><span class="token keyword">static</span><span class="token punctuation">::</span></span><span class="token function">who</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token comment">// B&#x7EE7;&#x627F;&#x4E86;A&#xFF0C;&#x91CD;&#x5199;A&#x7C7B;&#x91CC;&#x9762;&#x7684;who&#x65B9;&#x6CD5;&#x3002;</span>
<span class="token keyword">class</span> <span class="token class-name">B</span> <span class="token keyword">extends</span> <span class="token class-name">A</span><span class="token punctuation">{</span>
	<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">function</span> <span class="token function">who</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
		<span class="token keyword">echo</span> <span class="token number">222</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token variable">$a</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">B</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token variable">$a</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</pre><blockquote>
<p>[info] &#x8868;&#x683C;&#x8868;&#x8FBE;&#x7C7B;&#x76F8;&#x5173;&#x7684;&#x5173;&#x952E;&#x8BCD;</p>
</blockquote>
<table>
<thead>
<tr>
<th><strong>&#x5173;&#x952E;&#x8BCD;</strong></th>
<th><strong>&#x7C7B;&#x5916;&#x58F0;&#x660E;</strong></th>
<th><strong>&#x58F0;&#x660E;&#x7C7B;</strong></th>
<th><strong>&#x58F0;&#x660E;&#x5C5E;&#x6027;</strong></th>
<th><strong>&#x58F0;&#x660E;&#x65B9;&#x6CD5;</strong></th>
<th><strong>&#x89E3;&#x91CA;</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>const</td>
<td>&#x221A;</td>
<td></td>
<td>&#x221A;</td>
<td></td>
<td>&#x5B9A;&#x4E49;&#x7C7B;&#x5E38;&#x91CF;</td>
</tr>
<tr>
<td>extends</td>
<td></td>
<td>&#x221A;</td>
<td></td>
<td></td>
<td>&#x6269;&#x5C55;&#x7C7B;&#xFF0C;&#x7528;&#x4E00;&#x4E2A;&#x7C7B;&#x53BB;&#x6269;&#x5C55;&#x5B83;&#x7684;&#x7236;&#x7C7B;</td>
</tr>
<tr>
<td>public</td>
<td></td>
<td></td>
<td>&#x221A;</td>
<td>&#x221A;</td>
<td>&#x516C;&#x7528;&#x5C5E;&#x6027;&#x6216;&#x65B9;&#x6CD5;</td>
</tr>
<tr>
<td>protected</td>
<td></td>
<td></td>
<td>&#x221A;</td>
<td>&#x221A;</td>
<td>&#x79C1;&#x6709;&#x5C5E;&#x6027;&#x6216;&#x65B9;&#x6CD5;</td>
</tr>
<tr>
<td>private</td>
<td></td>
<td></td>
<td>&#x221A;</td>
<td>&#x221A;</td>
<td>&#x53D7;&#x4FDD;&#x62A4;&#x7684;&#x5C5E;&#x6027;&#x6216;&#x65B9;&#x6CD5;</td>
</tr>
<tr>
<td>abstract</td>
<td></td>
<td>&#x221A;</td>
<td>&#x221A;</td>
<td></td>
<td>&#x62BD;&#x8C61;&#x7C7B;&#x6216;&#x65B9;&#x6CD5;</td>
</tr>
<tr>
<td>final</td>
<td></td>
<td>&#x221A;</td>
<td></td>
<td>&#x221A;</td>
<td>&#x7C7B;&#x4E0D;&#x80FD;&#x88AB;&#x7EE7;&#x627F;</td>
</tr>
<tr>
<td>interface</td>
<td></td>
<td>&#x221A;</td>
<td></td>
<td></td>
<td>&#x521B;&#x5EFA;&#x63A5;&#x53E3;</td>
</tr>
<tr>
<td>implements</td>
<td></td>
<td>&#x221A;</td>
<td></td>
<td></td>
<td>&#x5B9E;&#x73B0;&#x63A5;&#x53E3;</td>
</tr>
<tr>
<td>parent::</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>&#x8BBF;&#x95EE;&#x7236;&#x7C7B;</td>
</tr>
<tr>
<td>$this-&gt;</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>&#x8BBF;&#x95EE;&#x672C;&#x7C7B;</td>
</tr>
<tr>
<td>self::</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>&#x8BBF;&#x95EE;&#x9759;&#x6001;</td>
</tr>
<tr>
<td>static::</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>&#x540E;&#x671F;&#x9759;&#x6001;&#x7ED1;&#x5B9A;</td>
</tr>
<tr>
<td>namespace</td>
<td>&#x221A;</td>
<td></td>
<td></td>
<td></td>
<td>&#x521B;&#x5EFA;&#x547D;&#x540D;&#x7A7A;&#x95F4;</td>
</tr>
</tbody>
</table>

      </div>
      
      
    
    
    
    
    
    
    
    
  
    </body></html>